Skip to main content

read_capped

Function read_capped 

Source
pub async fn read_capped(
    store: &Arc<dyn ObjectStore>,
    key: &Path,
    max_bytes: u64,
) -> Result<Bytes, ObjectStoreError>
Expand description

Read a whole object, and reject it if its size exceeds max_bytes.

The function does a head() first, so it refuses an oversized object before it buffers any bytes. This is the guard against OOM on a corrupt or malicious object. The GET uses the HEAD version and etag when available. Its response size and streamed chunks are also checked, so an overwrite cannot bypass the cap.

ยงErrors