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

Uploaded files always come as application/octet-stream #9

Closed
rbaprado opened this issue Jan 23, 2015 · 6 comments
Closed

Uploaded files always come as application/octet-stream #9

rbaprado opened this issue Jan 23, 2015 · 6 comments
Labels

Comments

@rbaprado
Copy link

Hello,

Is there a way to fix this? My backend depends on the mime-type to detect valid images and has problems to receive files from Android because of this...

Thanks.

@ocram ocram added the bug label Jan 23, 2015
@ocram
Copy link
Contributor

ocram commented Jan 23, 2015

Thanks for pointing this out. We haven't checked this yet, so can you tell what platform versions this happens on?

  • Android 4.3 and below
  • Android 5.0 and above
  • both

By the way, you should neither rely on file extensions nor on MIME types for security checks. For all other purposes, that may be fine, of course.

@rbaprado
Copy link
Author

I tested on 4.4.4 and 4.1.2, the behavior is the same.

Thanks for the advice, my application does not rely on mime types anymore
due to the security risk you pointed out, but I came across this issue and
thought it might be a good feature.
Em Fri Jan 23 2015 at 18:26:17, Marco [email protected] escreveu:

Thanks for pointing this out. We haven't checked this yet, so can you tell
what platform versions this happens on?

  • Android 4.3 and below
  • Android 5.0 and above
  • both

By the way, you should neither rely on file extensions nor on MIME types
for security checks. For all other purposes, that may be fine, of course.

Reply to this email directly or view it on GitHub
#9 (comment)
.

@ocram
Copy link
Contributor

ocram commented Jan 23, 2015

Well, on 4.4.4, file uploads should not be available at all. Apart from that, you're right, file uploads should work as in the user's normal browser.

We have tested MIME type detection with this library and it seems to work as intended. Generally, most browsers detect the MIME type by looking at the file extension, anyway.

Can you please check what MIME type is detected if you upload the same image from your desktop browser or from the Android system browser?

@ocram ocram added invalid and removed bug labels Jan 24, 2015
@ocram
Copy link
Contributor

ocram commented Jan 24, 2015

This has now been tested on platforms both with the old WebView (4.3 and below) and with the new Chromium WebView (5.0 and above).

File uploads are working fine and MIME types are added by the WebView as well, e.g. like this:

Content-Disposition: form-data; name="my-file-input"; filename="my-file.png"
Content-Type: image/png

You should inspect the raw HTTP request and see if you're receiving this as well. If not, this may be due to the file you upload, the form HTML or the browser that is used -- but it seems at least with this library, everything is fine in that respect.

@ocram ocram closed this as completed Jan 24, 2015
@rbaprado
Copy link
Author

I will look into that. Just to let you know that I will be working for the
next few days in another project, so, don't hold you breath :-)

Thanks for the support, though.

Em Fri Jan 23 2015 at 22:11:23, Marco [email protected] escreveu:

This has now been tested on platforms both with the old WebView (4.3 and
below) and with the new Chromium WebView (5.0 and above).

File uploads are working with and MIME types are also added by the WebView,
e.g. like this:

Content-Disposition: form-data; name="my-file-input"; filename="my-file.png"
Content-Type: image/png

You should inspect the raw HTTP request and see if you're receiving this
as well. If not, this may be due to the file you upload, the form HTML or
the browser that is used -- but it seems at least with this library,
everything is fine in that respect.

Reply to this email directly or view it on GitHub
#9 (comment)
.

@ocram
Copy link
Contributor

ocram commented Mar 1, 2015

It turned out there is some special (and wrong) behaviour on Android 4.4.3 and 4.4.4 which is explained here: #14

@1170762202 1170762202 mentioned this issue Dec 16, 2022
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