Skip to content

Commit 9ad9195

Browse files
committed
Add proper logging into s3 functions
1 parent e015b5d commit 9ad9195

File tree

1 file changed

+8
-1
lines changed
  • src/webserver/database/sqlpage_functions

1 file changed

+8
-1
lines changed

src/webserver/database/sqlpage_functions/s3.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ pub(super) async fn upload_to_s3<'a>(
2727
if !full_path.starts_with(web_root) {
2828
anyhow::bail!("Security violation: Access denied to file outside web root");
2929
}
30-
tokio::fs::read(&full_path).await.with_context(|| format!("Unable to read file {}", full_path.display()))?
30+
tokio::fs::read(&full_path).await.map_err(|e| {
31+
log::error!("Failed to read file {}: {}", full_path.display(), e);
32+
e
33+
}).with_context(|| format!("Unable to read file {}", full_path.display()))?
3134
} else {
3235
// Assume base64
3336
use base64::Engine;
3437
base64::engine::general_purpose::STANDARD
3538
.decode(data.as_bytes())
39+
.map_err(|e| {
40+
log::error!("Base64 decode failed: {}", e);
41+
e
42+
})
3643
.context("Invalid base64 data")?
3744
};
3845

0 commit comments

Comments
 (0)