locked
Downloading via XHR and writing large files using WinJS fails with message "Not enough storage is available to complete this operation"

    Question

  • Hello,

    I have an issue that some user are experiencing but I can't reproduce it myself on my laptop. What I am trying to do it grab a file (zip file) via XHR. The file can be quite big, like 500Mb. Then, I want to write it on the user's storage.

    Here is the code I use:

    DownloadOperation.prototype.onXHRResult = function (file, result) {
        var status = result.srcElement.status;
        if (status == 200) {
            var bytes = null;
            try{
                bytes = new Uint8Array(result.srcElement.response, 0, result.srcElement.response.byteLength);
            } catch (e) {
                try {
                    Utils.logError(e);
                    var message = "Error while extracting the file " + this.fileName + ". Try emptying your windows bin.";
                    if (e && e.message){
                        message += " Error message: " + e.message;
                    }
                    var popup = new Windows.UI.Popups.MessageDialog(message);
                    popup.showAsync();
                } catch (e) { }
                this.onWriteFileError(e);
                return;
            }
            Windows.Storage.FileIO.writeBytesAsync(file, bytes).then(
                this.onWriteFileComplete.bind(this, file),
                this.onWriteFileError.bind(this)
            );
        } else if (status > 400) {
            this.error(null);
        }
    };

    The error happens at this line:

    bytes = new Uint8Array(result.srcElement.response, 0, result.srcElement.response.byteLength);

    With description "Not enough storage is available to complete this operation". The user has only a C drive with plenty of space available, so I believe the error message given by IE might be a little wrong. Maybe in some situations, Uint8Array can't handle such large file? The program fails on a "ASUSTek T100TA" but not on my laptop (standard one)

    Can somebody help me with that? Is there a better way to write a downloaded binary file to the disk not passing via a Uint8Array?

    Thanks a lot,

    Fabien

    Sunday, January 18, 2015 11:19 PM

Answers

All replies

  • Hi Fabien,

    If Uint8Array works fine on the other computer, it should not be the problem of the API, but instead it could be the setting or configuration for IE.

    Actually using XHR for 500MB zip file is not suggested, base on the documentation: How to download a file, XHR wraps an XMLHttpRequest call in a promise, which is not a good approach for big item download, please use Background Transfer instead, which is designed to receive big items.

    Simply search on the Internet, and looks like the not enough storage error is a potential issue while using XMLHttpRequest: http://forums.asp.net/p/1985921/5692494.aspx?PRB+XMLHttpRequest+returns+error+Not+enough+storage+is+available+to+complete+this+operation, however I'm not familiar with how to solve the XMLHttpRequest issues.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, January 19, 2015 6:52 AM
    Moderator
  • Hello and thanks a lot for the quick answer,

    Background Transfer looks like the way to go. I had some weird bugs with it as well but i'll try to work them out :)

    Fabien

    Monday, January 19, 2015 8:22 PM