Javascript Download Application Octet Stream

Join GitHub today

The Mozilla Toolkit is a set of APIs, built on top of Gecko, which provide advanced services to XUL applications. These services include Profile Management, Chrome Registration, Browsing History, Extension and Theme Management, Application Update Service, and Safe Mode.More info. If you are going to treat any incoming data as if it was 'Some bytes that might represent something but we don't know what', then why not just ignore the content type you receive instead of trying to force the browser to claim it doesn't know what it is sending? You should urlencode the name before you print it. Spaces and a lot of other characters aren't allowed in URLs, they should be replaced by codes such as%20 for the space.

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up 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

Comments

Application/octet-stream Google

commented Jun 2, 2017

I am trying to download a stream from a blob storage and when I save it as a wav file I am unable to reproduce it on my computer
var blob = new Blob(httpResponse, { type: 'application/octet-stream' });
saveAs(blob, filename + '.wav');

The httpResponse has the wav audio format:
RIFFD)�........WAVEfmt.....................

Any ideas?

commented Jun 2, 2017

Must start making a wiki page about this same kind of question

I will make it sort this time.

  • Download the response as blob (using responseType = 'blob')
  • Or if u are using fetch (res.blob())
  • If the file is coming from the server u might as well use content-disposition attachment header, it has better cross browser support and don't need any javascript

commented Jun 2, 2017

But the response is not a blob object ,is an array of bytes from a wav file.
The file is created fine but it is corrupted.

commented Jun 2, 2017

what do you mean with it's an array?
Can you show me the hole method you use to download the wav file?

Stream

commented Jun 6, 2017•
edited

Javascript Download Application Octet Stream Files

The method to get the audio file from the server is as follows:
string sasBlobToken = cloudBlob.GetSharedAccessSignature(sasConstraints);
string uri = cloudBlob.Uri + sasBlobToken;
var stream = await cloudBlob.OpenReadAsync();
byte[] signal = null;
MemoryStream m = new MemoryStream();
if (cloudBlob != null)
{
cloudBlob.DownloadToStream(m);
}

Then I call this method in my angular controller:

getWav().success(function (item) {
var blob = new Blob([item], { type: 'audio/x-wav' });
saveAs(blob, 'audio.wav');
}

commented Jul 7, 2017•
edited

I am having same issue

file gets created but is corrupt

if do a hex diff seems to be thinking its UTF-8 and re-encoding bytes

UPDATE:

was resolved by setting the response options to

then in my case using Angular2

forcing the response to server up a blob for me

Application octet stream files

commented Jul 29, 2017

@lararogu this issue looks like it has been resolved. Presse close it if resolved.

Octet
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment