Skip to main content

get_object_bytes

Function get_object_bytes 

Source
pub async fn get_object_bytes(
    client: &Client,
    bucket: &str,
    key: &str,
    max_bytes: u64,
) -> Result<BytesPayload, AppError>
Expand description

Fetch the first max_bytes bytes of bucket/key as base64-encoded binary.

Uses a Range: bytes=0-<max_bytes-1> request so large objects are not fully downloaded. Returns a BytesPayload with the base64-encoded body, total content length, ETag, and a truncated flag.

ยงErrors

  • AppError::AccessDenied โ€” s3:GetObject permission denied.
  • AppError::NotFound โ€” bucket or key does not exist.
  • AppError::Network โ€” any other SDK or transport error.