Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:53:29+00:00 2026-05-25T17:53:29+00:00

I am trying to create a google-chrome-extension that will download an mp3 file. I

  • 0

I am trying to create a google-chrome-extension that will download an mp3 file. I am trying to use HTML5 blobs and an iframe to trigger a download, but it doesn’t seem to be working. Here is my code:

var finalURL = "server1.example.com/u25561664/audio/120774.mp3";

var xhr = new XMLHttpRequest();
    xhr.open("GET", finalURL, true);
    xhr.setRequestHeader('Content-Type', 'application/octet-stream');
    xhr.onreadystatechange = function() 
    {
        if(xhr.readyState == 4 && xhr.status == 200) 
        {   
            var bb = new (window.BlobBuilder || window.WebKitBlobBuilder)();
            bb.append(xhr.responseText);
            var blob = bb.getBlob("application/octet-stream");

            var saveas = document.createElement("iframe");
            saveas.style.display = "none";

            saveas.src = window.webkitURL.createObjectURL(blob); 

            document.body.appendChild(saveas);

            delete xhr;
            delete blob;
            delete bb;
        }
    }
 xhr.send();

When looked in the console, the blob is created correctly, the settings look right:

size: 15312172
type: “application/octet-stream”

However, when I try the link created by the createObjectURL(),

blob:chrome-extension://dkhkkcnjlmfnnmaobedahgcljonancbe/b6c2e829-c811-4239-bd06-8506a67cab04

I get a blank document and a warning saying

Resource interpreted as Document but
transferred with MIME type
application/octet-stream.

How can get my code to download the file correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:53:29+00:00Added an answer on May 25, 2026 at 5:53 pm

    The below code worked for me in Google chrome 14.0.835.163:

    var finalURL = "http://localhost/Music/123a4.mp3";
    var xhr = new XMLHttpRequest();
    xhr.overrideMimeType("application/octet-stream");
    //xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
    xhr.open("GET", finalURL, true);
    xhr.responseType = "arraybuffer";
    xhr.onload = function() {
          var bb = new (window.BlobBuilder || window.WebKitBlobBuilder)();
          var res = xhr.response;
          if (res){
              var byteArray = new Uint8Array(res);
          }
          bb.append(byteArray.buffer);
          var blob = bb.getBlob("application/octet-stream");
          var iframe = document.createElement("iframe");
          iframe.style.display = "none";
          iframe.src = window.webkitURL.createObjectURL(blob);
          document.body.appendChild(iframe);
    };
    xhr.send(null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create Google Chrome extension that will send interesting links to
I'm trying to create a Google Chrome extension that presses a button on page
I am trying to create a simple javascript based extension for Google Chrome that
I'm trying to create an extension using this docs: http://code.google.com/chrome/extensions/content_scripts.html I want a part
I am trying to create a chrome extension using HTML5 WebSockets and can't get
I'm trying to create a Google Chrome Extension. This worked for me: { name:
I am trying to create a Google Chrome extension where a user would highlight
I'm trying to create an extension for chrome that auto refreshes the page when
I'm trying to write a simple google extension that will upon clicking ctrl+alt+x search
I am trying to create a simple google chrome extension which can convert selected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.