leon / angular-upload

Upload service with iframe fallback and some nice directives to go with it.
MIT License
234 stars 100 forks source link

arraybuffer response problem after upload #33

Closed fatihpolatli closed 9 years ago

fatihpolatli commented 9 years ago

hi,

there is a problem when byte array is returned on response after uploading file. i use this for excel files. for a stuation, i upload an excel file and another excel data is returned in response as arraybuffer. bu if you dont set an responseType:"arraybuffer" property on "options" object, it doesnt create a valid excel file. for that, i did a modification;

i added this to params;

isArrayBuffer : '@' // ADDED BY FATIH POLATLI

and added this under options object; // ADDED BY FATIH POLATLI

        if(scope.isArrayBuffer === true || scope.isArrayBuffer === 'true'){

          options.responseType = "arraybuffer";
        }
        //

you can set it as attribute now and it works;

is-array-buffer="true";

it may be good to add this to project if you want.

thanks

leon commented 9 years ago

Arraybuffers are not supported on older browsers, and this plugin needs to work on older browsers. If you know that you have a newer browser there are simpler ways of getting the job done with FormData.