This diff implements blob uploading using multipart/form-data. Details are in the linear task.
Depends on D7482
Differential D7483
[services][blob] Add upload blob HTTP handler bartek on Apr 18 2023, 12:04 AM. Authored by Tags None Referenced Files
Details This diff implements blob uploading using multipart/form-data. Details are in the linear task. Depends on D7482 Used Postman client to upload a large file (more than 5MB to exceed the single S3 part limit). The file was uploaded successfully.
Diff Detail
Event TimelineComment Actions Might be nice to factor out all of the failable s3 code, which returns an s3 error, then we can just assert the error once from the calling code. while let Some(mut blob_field) = payload.try_next().await? { let field_name = blob_field.name(); if field_name != "blob_data" { warn!( field_name, "Malfolmed request: 'blob_data' multipart field expected." ); return Err(ErrorBadRequest("Bad request")); } upload_blob_to_s3(blob_field).await.map_err(handle_s3_error)?; }
Comment Actions I should've explain this in the diff description. Basically, the whole multipart stream consists of multiple Fields (a form field) where each field has its own stream of data bytes. For each field, I iterate over the stream and join the bytes to receive full field content.
Note that this endpoint uploads a single blob, regardless of the input partitioning.
|