improve error handling in streaming

Signed-off-by: Alexey Aristov <aav@acm.org>
This commit is contained in:
Alexey Aristov
2025-08-29 16:18:39 +02:00
parent 281cfc7ff7
commit d0ac7a3467
+10 -4
View File
@@ -251,10 +251,16 @@ pub async fn get(request: HttpRequest) -> HandlerResult<HttpResponse> {
yield Ok(Bytes::from(inline));
},
None => {
let mut response = s3.get_object().bucket(&CONFIG.s3_bucket).key(parts.data.blob).send().await.unwrap();
while let Some(bytes) = response.body.next().await {
yield Ok(bytes?);
match s3.get_object().bucket(&CONFIG.s3_bucket).key(parts.data.blob).send().await {
Ok(mut response) => {
while let Some(bytes) = response.body.next().await {
yield Ok(bytes?);
}
},
Err(error) => {
yield Err(std::io::Error::new(std::io::ErrorKind::Other, error));
break;
}
}
}
}