pub fn list_multipart_uploads(
ctx: &Ctx,
prefix: &str,
) -> impl Future<Output = Result<Vec<PendingUpload>>> + Send + use<>Expand description
The multipart uploads in progress whose key starts with prefix, oldest first.
For a cleanup task that aborts uploads left behind, or for completing
the upload of an output whose uploader never reported. Calls
ListMultipartUploads on R2’s S3 API (one subrequest per 1,000 uploads;
R2_* settings as list_parts); in debug builds, the uploads started
with create_multipart or
multipart_uploads and not
finished.
Free plan: one R2 class A operation per 1,000 uploads.
§Errors
Error::Internal (500) when an R2_* setting
is missing (release builds), or R2 answers an error.
§Examples
use ocre::{Ctx, Result, storage};
// Keeps only the newest upload of each output (a retried task starts a new one).
async fn drop_older_uploads(ctx: &Ctx, key: &str) -> Result<()> {
let mut uploads = storage::list_multipart_uploads(ctx, key).await?;
uploads.retain(|upload| upload.key == key);
uploads.pop(); // the newest
for upload in uploads {
storage::abort_multipart(ctx, key, &upload.upload_id).await?;
}
Ok(())
}