Skip to main content

validate_object_key

Function validate_object_key 

Source
pub fn validate_object_key(key: &str) -> Result<(), S3ServiceError>
Expand description

Validate an S3 object key.

Rules:

  • 1-1024 bytes in length
  • Must be valid UTF-8 (enforced by the &str type)

§Errors

Returns S3ServiceError::InvalidArgument if the key is empty or exceeds 1024 bytes, or S3ServiceError::KeyTooLong if the key is too long.

§Examples

use rustack_s3_core::validation::validate_object_key;

assert!(validate_object_key("photos/2024/image.jpg").is_ok());
assert!(validate_object_key("").is_err());