drogon icon indicating copy to clipboard operation
drogon copied to clipboard

Multipart data per-part Content-Type

Open timomrs opened this issue 3 years ago • 1 comments

HttpFileUploadRequest should support defining Content-Type for each part. That is, the current per-part header is of the form

content-disposition: form-data; name="<itemName>"; filename="<fileName>"

where itemName and fileName are filled from the corresponding fields of UploadFile, as seen in https://github.com/drogonframework/drogon/blob/master/lib/src/HttpRequestImpl.cc around line 282. However, the full format as described in https://www.ietf.org/rfc/rfc2388.txt also allows for a content-type -field, which is required by many APIs. In other words the full format should be

content-disposition: form-data; name="<itemName>"; filename="<fileName>"
content-type=<contentType>

where contentType could be for example "image/jpeg".

Suggested solution: add a new string field _contentType to UploadFile and if it's non-empty, add it to the corresponding part when building the multipart request.

timomrs avatar May 18 '22 13:05 timomrs

Thanks for the feature request! I agree :+1:

rbugajewski avatar May 18 '22 15:05 rbugajewski

Forgot to close this, resolved when PR #1279 was merged, thanks!

timomrs avatar Sep 07 '22 06:09 timomrs