Skip to content

Support for file streaming instead of downloading to disk #450

@mikhailushka

Description

@mikhailushka

Hi!

We discovered that while uploading a video from the provided URL, the file is downloaded to disk, in the temporary directory.

This happening here:

file = URI.open(path_or_url)

This behavior interferes with the operation of pods in our cluster, which have a limit on ephemeral local storage usage.

To work around this limitation, we used the following draft patch, which allows streaming a file instead of downloading:

class Yt::Models::Account
  def upload_video(path_or_url, params = {})
    file = if path_or_url.to_s.start_with?('https://', 'http://')
      # fix here
      Down.open(path_or_url, rewindable: false)
    else
      File.open(path_or_url, 'r')
    end
    session = resumable_sessions.insert file.size, upload_body(params)

    session.update(body: file) do |data|
      Yt::Video.new(
        id: data['id'],
        snippet: data['snippet'],
        status: data['status'],
        auth: self
      )
    end
  ensure
    file.close if file.respond_to?(:close)
  end
end

Please, add a streaming support in gem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions