gleetube/upload
Types
Result of a single upload chunk operation.
pub type UploadResult(a) {
Progress(bytes_sent: Int, total: Int)
Done(result: a)
}
Constructors
-
Progress(bytes_sent: Int, total: Int)Upload is still in progress. Contains bytes uploaded so far.
-
Done(result: a)Upload is complete. Contains the decoded API response.
Values
pub fn init(
client: client.Client,
path: String,
params: List(#(String, String)),
metadata: json.Json,
media: media.Media,
) -> Result(String, error.GleeTubeError)
Initiate a resumable upload and return the resumable session URI.
pub fn next_chunk(
client: client.Client,
resumable_uri: String,
media: media.Media,
offset: Int,
decoder: decode.Decoder(a),
) -> Result(UploadResult(a), error.GleeTubeError)
Upload the next chunk to the resumable URI. Returns Progress if more chunks remain, or Done with the decoded result.
pub fn upload_all(
client: client.Client,
path: String,
params: List(#(String, String)),
metadata: json.Json,
media: media.Media,
decoder: decode.Decoder(a),
) -> Result(a, error.GleeTubeError)
Upload all chunks in a single call (convenience function). Handles the full resumable upload flow: init -> loop chunks -> return result.