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 9144711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:20:11+00:00 2026-06-17T10:20:11+00:00

I’m retrieving an ArrayBuffer over XHR and want to save it to the FileSystem

  • 0

I’m retrieving an ArrayBuffer over XHR and want to save it to the FileSystem API using a FileWriter. The FileWriter expects a Blob and the Blob constructor won’t take an ArrayBuffer, it takes an ArrayBufferView.

There are many ArrayBufferViews to choose from, how do I know which is the correct to use?

  • 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-06-17T10:20:12+00:00Added an answer on June 17, 2026 at 10:20 am

    At MDN, you can find an overview of all available ArrayBufferView subclasses:

    Type Bytes Description Equivalent C type
    Int8Array 1 8-bit twos complement signed integer int8_t
    Uint8Array 1 8-bit unsigned integer uint8_t
    Uint8ClampedArray 1 8-bit unsigned integer (clamped) uint8_t
    Int16Array 2 16-bit twos complement signed integer int16_t
    Uint16Array 2 16-bit unsigned integer uint16_t
    Int32Array 4 32-bit twos complement signed integer int32_t
    Uint32Array 4 32-bit unsigned integer uint32_t
    Float32Array 4 32-bit IEEE floating point number float
    Float64Array 8 64-bit IEEE floating point number double
    BigInt64Array 8 64-bit two’s complement signed integer int64_t
    BigUint64Array 8 64-bit unsigned integer uint64_t

    Basically, this lists what memory spaces each item of the array would occupy and if it’s a plain number or a FP number. I’m not sure what languages you’re familiar with, but if it also covers Java, then it is basically the same choice as you’d make on byte[], short[], int[], float[] and double[] (Java is always signed, so that part doesn’t matter).

    We know, binary data like images is usually represented as a byte array. A short/int/long array can also, but this is a waste of memory space. If you would store a 100KB image (note that "B" stands for byte, which is 8 bits) in an int array instead of a byte array, then it would occupy 400KB of memory, which is a waste of 300KB. So the smallest one, Int8Array, would already suffice with regard to memory space. If you’d ever like to programmatically traverse it — which is very unlikely in this case — as an unsigned array, then you may opt for the Uint8Array instead where each item holds values 0 to 255 instead of values -128 to 127.

    Here’s a copy’n’paste’n’runnable kickoff example which downloads an image file from the server, saves it to the temporary local storage space and presents it as an <img> in the body (little jQuery is required for that part). This example assumes that the image.png file is located in the same base folder as the JS (or HTML, in case JS is inlined) file is been downloaded from:

    window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
    window.requestFileSystem(window.TEMPORARY, 1024*1024, startDownload, errorHandler);
    
    var errorHandler = function(error) {
        console.log('FS error: ' + error);
    }
    
    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'image.png', true);
    xhr.responseType = 'arraybuffer';
    
    function startDownload(fileSystem) {
        xhr.onload = function(event) {
            var content = new Int8Array(this.response);
            fileSystem.root.getFile('/image.png', { 'create': true }, function(fileEntry) {
                fileEntry.createWriter(function(fileWriter) {
                    fileWriter.onwriteend = function(event) {
                        $('body').append('<p>Image successfully downloaded:</p>')
                                 .append('<p><img src="' + fileEntry.toURL() + '"/></p>');
                    };
    
                    var blob = new Blob([content], { type: 'image/png' });
                    fileWriter.write(blob);
                }, errorHandler);
            });
        }
    
        xhr.send();
    }
    

    Note, as of the current state, this works in Chrome, Edge and Opera only and not (yet?) in Safari nor Firefox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.