Skip to main content

parse_copy_source

Function parse_copy_source 

Source
pub fn parse_copy_source(
    source: &str,
) -> Result<(String, String, Option<String>), S3ServiceError>
Expand description

Parse the x-amz-copy-source header value into bucket, key, and optional version ID components.

The copy source header uses the format /bucket/key or bucket/key, with an optional ?versionId=<vid> suffix. Percent-encoded characters in the key are decoded.

§Errors

Returns S3ServiceError::InvalidArgument if the copy source string is empty or malformed.

§Examples

use rustack_s3_core::utils::parse_copy_source;

let (bucket, key, vid) = parse_copy_source("my-bucket/my-key").unwrap();
assert_eq!(bucket, "my-bucket");
assert_eq!(key, "my-key");
assert!(vid.is_none());