Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a way to set filename for Content-Disposition when uploading file-data from memory #702

Open
DHager opened this issue Feb 22, 2022 · 4 comments
Labels

Comments

@DHager
Copy link

DHager commented Feb 22, 2022

I ran into an issue where a remote server would refuse data (inside a multipart) unless the Content-Disposition header contained a filename, but I couldn't find any way to set one.

To be specific, in a multipart-part the server required:

Content-Disposition: form-data; name="data_form_input_name"; filename="original_filename.dat"

But refused to accept:

Content-Disposition: form-data; name="data_form_input_name"

I looked at the documentation for encode_form/1 but I wasn't able to solve the issue with ExtraHeaders, because the goal is to modify the existing header, rather than adding new siblings.

@DHager
Copy link
Author

DHager commented Feb 22, 2022

My current workaround is to save the data to a temporary file on disk (with a specific name), use {file, Path, Name, ExtraHeaders}, and then delete the temporary file afterwards... But it's annoying.

@benoitc
Copy link
Owner

benoitc commented Apr 8, 2022

we can have a pattern that just place needed headers instead. I will think about it

@benoitc benoitc added the feature label Apr 8, 2022
@DHager
Copy link
Author

DHager commented Aug 15, 2022

Hi, any updates on this?

One option may be to add a new item to the list, {file_in_memory, Name, FileName, Data, ExtraHeaders}.

This is in contrast to {file, Path, Name, ExtraHeaders}, where the Path is indirectly supplying both FileName and Data through a disk-access.

@DHager
Copy link
Author

DHager commented May 25, 2023

Ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants