Skip to main content

presign_parts

Function presign_parts 

Source
pub fn presign_parts(
    endpoint: &S3Endpoint,
    key: &str,
    upload_id: &str,
    parts: &[u16],
    now: i64,
    expires_in: u64,
) -> Result<PartUrls>
Expand description

Presigned PUT URLs of parts of the upload upload_id of key, valid expires_in seconds.

§Errors

Error::BadRequest for a part number outside 1 to 10,000 or too many parts at once; Error::Internal for an out-of-range expires_in.

§Examples

use ocre::storage::{S3Endpoint, presign_parts};

let r2 = S3Endpoint::r2("acc", "blog-storage", "AKID", "secret");
let urls = presign_parts(&r2, "uploads/a", "up1", &[1, 2], 1_790_000_000, 3600).unwrap();
assert!(urls.urls[&2].contains("partNumber=2&uploadId=up1"));