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

Empty Content-Type when using attach_file #1236

Closed
darthdeus opened this issue Feb 4, 2014 · 5 comments
Closed

Empty Content-Type when using attach_file #1236

darthdeus opened this issue Feb 4, 2014 · 5 comments

Comments

@darthdeus
Copy link

When I attach a file via attach_file and then check the content type in the file in the params, it's empty.

However if I upload the same file in the same form manually and check the same way, I'll get a proper content type.

@darthdeus
Copy link
Author

So I've traced this issue down to the mime-types gem, which is internally being used by rack-test to detect the content type of the file. Unfortunately it only does detection by extension name, which isn't there for the file I'm uploading (.p12)

@jnicklas
Copy link
Collaborator

jnicklas commented Feb 4, 2014

Yeah, mime-types is not going to be perfect, unfortunately.

@phansch
Copy link

phansch commented Feb 25, 2014

I just came across the same problem today. Trying to upload an .ics file via attach_file, it does not set the content type. However, when manually uploading the file, the content type is being set just fine (to text/calendar). Also, the mime-types gem seems to support text/calendar files: text.yaml#22

Any idea, why attach_file is not setting the content_type in this case?

@darthdeus
Copy link
Author

@phansch I'm not sure, in my case the file type was completely missing in the mime-types, but seems you're having a different issue.

@jsgarvin
Copy link

Sorry to comment here on something that's clearly not capybara's problem, but this is the only place I've found anyone else that has run into this.

Is there a workaround? Registering the new mime-type with Mime::Type.register_alias doesn't seem to have any effect for me. I can't find anything in the mime-type gem docs regarding adding custom mime-types. Not sure what else to try. I hope I'm overlooking something obvious.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants