Download Application Octet Stream Attachments

Posted on by

Print

I can download the audio file and it works correctly. What I want to know is how to, if possible, get the name of the file as it is downloaded instead of giving it my own name. Also, is it possible to get the file without having to read from the stream (maybe some library that does it for you)? I kind of want to hide the dirty stuff. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site. Content type 'application/octet-stream' will always cause Firefox to show the 'open with' download dialog. To avoid this download you would have to configure the server to send another content type and possibly change the file extension of the file.

Active7 years, 8 months ago

I've written a download Servlet to return a file based on a messageID parameter. Below is the doGet method.

I then wrote some code to retrieve the file.

Now this code works fine. I can download the audio file and it works correctly. What I want to know is how to, if possible, get the name of the file as it is downloaded instead of giving it my own name. Also, is it possible to get the file without having to read from the stream (maybe some library that does it for you)? I kind of want to hide the dirty stuff.

Thanks

Sotirios DelimanolisSotirios Delimanolis
221k43 gold badges543 silver badges612 bronze badges

Youtube Application Octet Stream

2 Answers

With attachment, the file will be served with the provided name properly. When inline, browsers seem to ignore filename, and usually give the servletname part of the URL as default name when saving the inline contents.

You could try mapping that URL to an appropriate filename, if that is suitable.

Here's a SO related question: Securly download file inside browser with correct filename

You may also find this link useful: Filename attribute for Inline Content-Disposition Meaningless?

I think you cannot download file without streaming. For I/O you must use stream.

Community

Application/octet-stream Virus

Muhammad Imran TariqMuhammad Imran Tariq

C# Application Octet Stream

10.2k35 gold badges107 silver badges176 bronze badges

For setting the download file name do the following on response object in Servlet code

EDIT:I see you are already doing it. Just try removing the slashes you have added.

SantoshSantosh

Application Octet Stream Example

15.3k3 gold badges42 silver badges68 bronze badges

Not the answer you're looking for? Browse other questions tagged javajava-ee or ask your own question.