Skip to main content

max / makenotwork

s3-storage: add download_stream returning the SDK ByteStream
Author: Max J. <87768334+MaxJMath@users.noreply.github.com> · 2026-05-27 14:47 UTC
Commit: a259ef213babed8cce91aaf3c7cc6af18044be43
Parent: 5d6d93d
1 file changed, +18 insertions, -0 deletions
@@ -120,6 +120,24 @@ impl S3Client {
120 120 Ok((bytes.into_bytes().to_vec(), content_type))
121 121 }
122 122
123 + /// Stream an object's body from S3 without buffering. Caller drives the
124 + /// `ByteStream` to disk or hands it to a layer that wants chunks.
125 + pub async fn download_stream(
126 + &self,
127 + key: &str,
128 + ) -> Result<aws_sdk_s3::primitives::ByteStream, String> {
129 + let resp = self
130 + .client
131 + .get_object()
132 + .bucket(&self.bucket)
133 + .key(key)
134 + .send()
135 + .await
136 + .map_err(|e| format!("S3 download failed: {e}"))?;
137 +
138 + Ok(resp.body)
139 + }
140 +
123 141 /// Delete an object from S3.
124 142 pub async fn delete(&self, key: &str) -> Result<(), String> {
125 143 self.client