Add a way to set filename on multipart requests
See original GitHub issueThis has already been discussed in #1063 #1092 #1096 and #1130, but I thought I’d open a separate issue to track this specifically.
RFC2388 describes the filename
header parameter of multipart/form-data
requests that Retrofit now uses. This parameter is required on some backend configurations. More details and examples can be found here.
We need a way of figuring out what the filename is. The problem with RequestBody
(which is a part of OkHttp) is that it doesn’t expose the filename when created with a File
.
Issue Analytics
- State:
- Created 8 years ago
- Comments:37 (8 by maintainers)
Top Results From Across the Web
Set name header of multipart-encoded file POST
The name is set from the key in your files dictionary. Just alter that key to set the name field to the desired...
Read more >How to send payload as a multipart/form File in a HTTP Request
You'll need to use a DataWeave script for the body of your request, similar to: %dw 2.0 import dw::module::Multipart input payload application/xml output ......
Read more >Using FormData Objects - Web APIs | MDN
The FormData object lets you compile a set of key/value pairs to send using XMLHttpRequest. It is primarily intended for use in sending...
Read more >Request Files - FastAPI
To receive uploaded files, first install python-multipart . E.g. pip install python-multipart . This is because uploaded files are sent as "form data"....
Read more >Upload files in ASP.NET Core - Microsoft Learn
The file is received from a multipart request and directly processed or saved by ... The following code removes the path from the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Using a map works (and may be the best option for beta versions of Retrofit 2 before they brought in OkHttp 3), but I believe they promoted
Multipart
for exactly this scenario. The current intended way to upload a file while specifying a filename (afaict) is usingMultipart.Part
. Something like this:Interface:
Client:
This is my code. This works…