I have got an Application/octet-stream file and want to read into memory encoded as utf-8. How can I do that with Python ?what is actually Application/octet-stream?
I have tried
But it does not work:
what I want is in alphabet
thank you very much
Application/octet-stream
means that the sender of the data (probably an HTTP server) had no idea what the data is. It's just an arbitrary data dump. The example output you give confirms that it's not UTF-8 since there shouldn't be any 0 bytes. It might be UTF-16-be
but then, it must be an even number of input bytes and you have 5.
That means the input data isn't valid in some way. Maybe if you speak with the person who gave it to you or which wrote the producer, that would help to find out what the data is supposed to be. Chances are it's not text at all.
I'm using Firefox 41.0.1 on Fedora 22.
I noticed this behaviour when I was trying to open a PNG image link on a GitLab site. The server replies with 'Content-Disposition:'inline; filename='logo.png'
and Content-Type:'application/octet-stream'
.
I want it to either display the image on the browser, or offer me to open it on the system default image viewer. I know it is possible, at least in Windows. See the GIF below kindly provided by @JourneymanGeek:
I made some tests using this tool and, apparently, when I click a link and the response headers contains the application/octet-stream
mime type, Firefox offers me to open the file using gedit, stating it's the default application.
xdg-open
also opens it in Eye of Gnome.application/octet-stream
isn't present on /usr/share/applications/defaults.list
$ grep 'gedit' /usr/share/applications/defaults.list
returns only text/plain=org.gnome.gedit.desktop
~/.mozilla/firefox/<profile>/mimeTypes.rdf
file and the issue persits.~/.local/share/applications/mimeapps.list
file and the issue still persists.Here's the Firefox file association screen:
So, again, my question is: is it possible to have Firefox either display the file on the browser (if it is a file it's able of rendering), or offering the correct application able of rendering it (if there's one on the system)?
Or does the server declaring the incorrect mime-type renders it all impossible?
Also, why is it thinking gedit
is the default octet-stream
handler? Is this correct?
I have also removed the ~/.local/share/applications/mimeapps.list
file and the issue still persists.
There is likely another mimeapps.list
elsewhere on the system. You can go through the list here, or search through your system with one of the following commands:
or
Check for any application/octet-stream
entries in those, and either comment them out or remove them.
Well, seems that Firefox will not fix this issue but I fixed it in my way removing the application/octet-stream=org.gnome.gedit.desktop
from my ~/.config/mimeapps.list
and using the add-on OpenDownload² to provide me the Run
option.
If the extension of the file being downloaded is correctly configured in the mimeapps.list
, firefox will open (run) it like a charm.
@Bob answered part 2 of the question: how to control which app opens the file.
The answer to part 1 is: Firefox downloads all files of type application/octet-stream by design. According to the HTTP standard, a compliant browser MUST NOT second-guess the server if a content-type is specified. Since octet-stream files contain arbitrary data, the browser should download them.
Most browsers ignore the standard in favor of user friendliness. Firefox does not. As stated in @Geyslan's answer, you would need to use a 3rd party extension to circumvent this design choice.
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave 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
Hi, thank you for the amazing repo! Instead of Content-Type: text/csv is it possible to set Content-Type as application/octet-stream for the attached csv files? thank you |
Hey, thanks for posting. I'm not sure why you would want that :)? It would help understanding how it would fit in the code. |
Thank you Pascal for your prompt reply. Based on my understanding all csv files send via yagmail are detected as 'Content-Type: text/csv; name='some_filename.csv' which is very nice feature because the content of the csv file is directly displayed inline in the body of the email. But for my case I would like to display the attachments as the attachements. See the screenshot. Thank you. |
Hi Radoslaw, just a guess... but are you mentioning the csv in |
Hi Pascal, yes I'm using
Thank you |
Could you try to see if it works for you with |
No luck.
here are the raw content of the email: |
I think I misunderstood the question! For me in gmail, the csv shows just fine (not inline, but as attachment). But you want |
Yes it works on gmail web client. See the part of the raw source, email send via perl's based on my research adding |
Had the same problem, still a bug at v0.10.212. @radoslawoska fix works. |
I have missed this one, thanks for bringing it back to attention. Feel free to make a PR as you've already found the fix, I'd gladly accept it and put it on pypi! |
csv files proper handling in the Mac mail client
thank you, PR created |
My client sent me file, suppose to be Backup file of MSAccess. They are using MSAccess as database application.
The file is around 80MB. I am expecting a backup file from them.
What I got is Binary (application/octet-stream) file type. It is neither SQL nor .BAK.
I am planning to get proper backup file from them in whatever format they have. And convert whole into MySQL format. Fortunately I have trail version of Red Gate software for 14 days that converts .BAK into SQL format.
I cannot open/use Binary (application/octet-stream) file or use it to convert into MySQL. How can I achieve proper bakcup file with Binary (application/octet-stream) file type? I would appreciate any solution to achieve my goal.
In my case, it was a file exported from Heroku using the commands:
The file was imported into my local database using:
See the docs here.