class

YandexDisk::Uploader

Inherits Reference < Object

Uploads a local file to the Disk, in resumable chunks when it is large.

Files at or below chunk_size go up in a single PUT. Larger ones are split and sent with Content-Range, so a connection that drops at 9 GB of a 10 GB dump only costs the chunk in flight, not the whole transfer.

The one thing that cannot be resumed is an expired link: upload URLs are valid for 30 minutes and the upload host keeps no state across them, so a refresh restarts the file from byte 0. Sizing chunk_size so a chunk comfortably fits in that window is what keeps that from happening.

Constants

DEFAULT_CHUNK_SIZE = (16_i64 * 1024) * 1024
LINK_LIFETIME = 25.minutes

Upload links live for 30 minutes; refresh early rather than race it.

Log = ::Log.for("yandex_disk.uploader")
MAX_LINK_ATTEMPTS = 3

How many times a whole file may be restarted on a fresh link.

STALE_LINK_STATUSES = {403, 404, 410}

Statuses the upload host answers with once a link is no longer usable.

Constructors

new(client : Client, chunk_size : Int64 = DEFAULT_CHUNK_SIZE, retry_policy : RetryPolicy = RetryPolicy.new)
Source

Instance methods

chunk_size
Source
upload(local : Path | String, remote : String, overwrite : Bool = true, & : Int64, Int64 -> ) : Int64

Uploads local to remote, returning the number of bytes sent.

on_progress is called with the running byte total after each chunk.

Source
upload(local : Path | String, remote : String, overwrite : Bool = true) : Int64

Uploads local to remote, returning the number of bytes sent.

on_progress is called with the running byte total after each chunk.

Source