pub fn create_multipart(
ctx: &Ctx,
key: &str,
content_type: &str,
) -> impl Future<Output = Result<String>> + Send + use<>Expand description
Starts a multipart upload of key with content_type, and returns its upload id.
For uploads the app drives itself: a service (a GPU worker, a partner’s
API) uploads the parts to presign_part URLs, then the app lists them
(list_parts) and assembles the object (complete_multipart).
Browser uploads of a form’s file use
multipart_uploads instead. Parts
are 5 MiB at least (but the last) and number 1 to 10,000. R2 drops an
upload left unfinished after 7 days; abort_multipart drops it at
once.
Free plan: one R2 class A operation, then one per part and one for the completion.
§Errors
Error::Internal (500) when the STORAGE
binding is missing or R2 fails.
§Examples
use ocre::{Ctx, Result, storage};
// Where a GPU worker uploads a 3-part result: the upload id and one URL per part, valid a day.
async fn output_target(ctx: &Ctx, job_id: i64) -> Result<(String, Vec<String>)> {
let key = format!("processed/{job_id}.mp4");
let upload_id = storage::create_multipart(ctx, &key, "video/mp4").await?;
let urls = (1..=3).map(|part| storage::presign_part(ctx, &key, &upload_id, part, 86_400)).collect::<Result<_>>()?;
Ok((upload_id, urls))
}