zip extraction issue in ipad safari

Hi,


We are downloading the zip file and extracting that file in our browser filesystem by using phonegap and javascript , for extracting we have used the zip.js library.


We are able to download the zip file successfully after that we are trying to extract that file.

The extraction code is working fine with chrome browser ,but the same code is not working in ipad(safari 6.0)

We are facing issue in converting the base64 to blob type

The below link also shows the same issue what we are facing.

http://stackoverflow.com/questions/17924501/javascript-convert-base64-to-blob-fa ils-in-safari-only

http://jsfiddle.net/jeanluca/4bn5G/ ( this is the working example which is working in chrome but not in iPad safari).


Please let us know if anyone faced this type of issue, anyhelp in this will be appreciated.



Thanks and Regards,

iPad 2 Wi-Fi, iOS 6.1.3

Posted on Sep 4, 2013 6:28 AM

Reply
8 replies

Sep 4, 2013 7:04 AM in response to msuper69

Thanks for your quick response.


Yes we did tried to find the solution on phonegap, but iPad safari browser is not supported to convert base64 to blob type. Every time we are getting 19 as a response.


We just wanted to know whether safari supports blob conversion or is there any other way to do it.


Sample Code:


var base64ToBlobSync = function(base64) {
var binary = atob(base64);
var len = binary.length;
var buffer = new ArrayBuffer(len);
var view = new Uint8Array(buffer);
for (var i = 0; i < len; i++) {
view[i] = binary.charCodeAt(i);
}
var contentType = 'application/zip'
alert("view.length "+view.length);
var blob = new Blob([view],{type: contentType});
return blob;
};

var blob = base64ToBlobSync(base64data); // this returns 19 always.



- - -

Regards

Sep 4, 2013 7:31 AM in response to msuper69

Hi Michael,


We are developing an app for ipad. We send a request to server for download a file which is in a zip format because this zip file contains bunch of other files which are required.


We want to store the zip file on browser file system, extract it and open one of the file in it.


We are not using native language (Objective C) to build application. We are building this app using online Adobe Phonegap build tool. The tools we are using to develop this app are:


  1. Phoengap
  2. SenchaTouch/Javascript
  3. HTML5
  4. CSS3


we are able to save .zip file in Safari browser but we are facing issues in extraction. Can you please provide us pointers to solve this issue?

Sep 9, 2013 5:04 AM in response to Rahul J

I was getting similar issues using Blob in safari (the magic 19 number). Seems like Safari does not play nicely with ArrayViews in Blob constructors. The workaround is to use original array buffer instead of the view. Checkout how these guys work around this problem : https://github.com/blueimp/JavaScript-Canvas-to-Blob/blob/master/js/canvas-to-bl ob.js


hasArrayBufferViewSupport = hasBlobConstructor && window.Uint8Array &&

(function () {

try {

return new Blob([new Uint8Array(100)]).size === 100;

} catch (e) {

return false;

}

}());


return new Blob([hasArrayBufferViewSupport?intArray:arrayBuffer],

{type: mimeString}

);

Hope this helps

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

zip extraction issue in ipad safari

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.