@@ -38,7 +38,7 @@ use rocket_cors::{AllowedOrigins, CorsOptions};
3838use serde:: { Deserialize , Serialize } ;
3939use store:: { FileState , Store } ;
4040
41- const CHUNK_SIZE : u64 = 1024 * 1024 ; // 1 MB
41+ const CHUNK_SIZE : u64 = ( 1024 * 1024 ) * 5 ; // 5 MB
4242
4343#[ derive( Serialize , Deserialize ) ]
4444struct InitBody {
@@ -441,16 +441,21 @@ async fn upload_finalize(
441441 . set_parts ( Some ( state. s3_parts . clone ( ) ) )
442442 . build ( ) ;
443443
444- let complete_multipart_upload_res = client
444+ client
445445 . complete_multipart_upload ( )
446446 . bucket ( & bucket_name)
447447 . key ( uuid)
448448 . upload_id ( & state. s3_upload_id )
449449 . multipart_upload ( completed_upload)
450450 . send ( )
451- . await ;
452-
453- complete_multipart_upload_res. map_err ( |_| Error :: InternalServerError ( Some ( "Could not complete S3 multipart upload" . to_owned ( ) ) ) ) ?;
451+ . await
452+ . map_err ( |e| {
453+ log:: error!( "S3 complete_multipart_upload failed: {:?}" , e) ;
454+ Error :: InternalServerError ( Some ( format ! (
455+ "Could not complete S3 multipart upload: {:?}" ,
456+ e
457+ ) ) )
458+ } ) ?;
454459
455460 // open the file to get the sender
456461 file = client
@@ -571,6 +576,9 @@ async fn rocket() -> _ {
571576 // conditionally mount the file download routes
572577 if s3_client. is_some ( ) {
573578 rocket = rocket. mount ( "/filedownload" , routes ! [ s3fileServer] ) ;
579+ if CHUNK_SIZE < 5 * 1024 * 1024 {
580+ log:: warn!( "S3 storage is enabled, but CHUNK_SIZE is less than 5 MB. This may lead to failing uploads." ) ;
581+ }
574582 } else {
575583 rocket = rocket. mount ( "/filedownload" , FileServer :: from ( config. data_dir ( ) ) ) ;
576584 }
0 commit comments