Giter Club home page Giter Club logo

jszip-utils's Introduction

JSZipUtils

A collection of cross-browser utilities to go along with JSZip, see http://stuk.github.io/jszip-utils for all the documentation.

It has two parts, one for every browsers and one for IE < 10. To use it :

<script type="text/javascript" src="dist/jszip-utils.js"></script>
<!--
Mandatory in IE 6, 7, 8 and 9.
-->
<!--[if IE]>
<script type="text/javascript" src="dist/jszip-utils-ie.js"></script>
<![endif]-->

Development

Run npm test to lint, build, and launch a server at http://localhost:8080/test/ . Open the page in a browser to verify that the tests are passing.

If you have a Saucelabs account set the SAUCE_USERNAME and SAUCE_ACCESS_KEYenvironment variables to test remotely.

License

JSZipUtils is dual-licensed. You may use it under the MIT license or the GPLv3 license. See LICENSE.markdown.

jszip-utils's People

Contributors

dduponchel avatar jamesward avatar mark-bradshaw avatar netei avatar stuk avatar victornpb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jszip-utils's Issues

Set HTTP Request Header

Is there a way to set/add request header to the call?
I would need to add 'Cache-Control': "private, no-cache, no-store" .

function urlToPromise(url) { return new Promise(function(resolve, reject) { JSZipUtils.getBinaryContent(url, function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); }

HTTP Status Code 201 (Created) should be handled as success

We use dynamic image cache and in the case the cached thumbnail was just created the response status code is 201 instead of 200.

if (xhr.status === 200 || xhr.status === 0) {

->

if (xhr.status === 200 || xhr.status === 201 || xhr.status === 0) {

Can I cancel the request?

I am do requests in a for cycle and I need to cancel any request at any moment. Tanks for the help.

Error: Ajax error for filepath : 404 Not Found

H!
when i deploy and try to download then its say file not found
Error: Ajax error for /Areas/Client/UploadedFiles/2327/Driveshaft.dwg : 404 Not Found

Failed to load resource: the server responded with a status of 404 (Not Found)

when i upload jpq or pdf its works fine but .dwg file giving error

    var zip = new JSZip();
    var count = 0;   
    file_paths.forEach(function (url) {
        JSZipUtils.getBinaryContent(url, function (err, data) {
            if (err) {
                //throw err;
                showNotification(err);
            }
            count++;
            if (data != null) {
                zip.file(url, data, { binary: true });
             
                if (count == file_paths.length) {
                    debugger
                    zip.folder('' + uploadedDirectory+'' + id+'/')
                        .generateAsync({ type: 'blob' }).then(function (content) {
                            debugger

                            saveAs(content, zipFileName);
                        });
                }
            }
        });
    });
}```

CORS errors on getBinaryContent goes unnoticed

The commit 3c17932 replaced the isLocal check by a status check for 0.
Local files return a status of 0, but same goes when there's a CORS error preventing a remote request to be executed.

Requests with CORS errors are reported as successful with an empty content.

Follow Redirect

Currently JSZipUtils will not follow redirects.

It would be very helpful if it could follow a redirect when attempting to download a remote file.

How to import within React?

Hey,

Firstly thank you for the great work and for sharing it!

I have installed JsZipUtils via NPM and tried to import it like this:

import JSZipUtils from 'jszip-utils';

But the file can not be found. Also it's not mentioned in the documentation how I can import it within React.

Any tips?

Thanks!

Cross Origin Policy

I have a Cross Origin Policy error when i try to get the content of an image, can you tell me how to bypass it ? I've searched everywhere and all the solutions don't work :/

local request for a bad URL is treated as a good request

I've submitted a pull request on the part of the code that is causing me problems. When I ask for a zip file that is on localhost, the GetBinaryContent function doesn't seem to care what status I get back. If the url I request is a bad one, the function still proceeds as if I got a 200 status when in reality I got a 404 and it should fail.

Issue calling JSZipUtils from browser

I am trying to use the getBinaryContent() function in order to parse a Word document for docxtemplater, but every time the jszip-utils library is loaded I get a console error "Uncaught ReferenceError: module is not defined at jszip-utils.js:10" and I am subsequently unable to call the library. Any help would be appreciated.

Reading large zip file - JSZipUtil.getBinaryContent()

Hi Stuk,

Hope you're doing well. I'm using this library for one of the project and getting this error (please see below). This error occurred when the large zip file (max size: 8.8 MB on disk) used for reading the zip content. Below is the code snippet for reading the large zip file.

Can you please provide some feedback on this issue? As this is very important issue and we need to escalate urgently, so your feedback would be highly appreciable.

Code Snippet:

      new JSZip.external.Promise((resolve: any, reject: any) => {
        **JSZipUtils.getBinaryContent(filePath, (err: any, data: any)** => {
          if (err) {
            reject(err);
          } else {
            JSZip.loadAsync(data)
              .then(function(zip: any) {
                DataValidator.checkValidZipFile(zip).then((response) => {
                  setTimeout(() => {
                    let reportsMap: Map<string, Report> = ReportGenerator.getReports();
                    console.log("Report =>", reportsMap);
                    reportsResolve(reportsMap);
                  }, 1000);
                });
              }, function (error: any) {
                reportsReject(error);
              });
          }
        });

Javascript Error:

DataValidator.ts:218 ERROR Error: Uncaught (in promise): Error: InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').
Error: InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').
at xhr.onreadystatechange [as __zone_symbol__ON_PROPERTYreadystatechange] (index.js:110:32)
at XMLHttpRequest.wrapFn (zone.js:818:43)
at _ZoneDelegate.invokeTask (zone.js:446:35)
at core.mjs:23891:55
at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:23891:36)
at _ZoneDelegate.invokeTask (zone.js:445:64)
at Object.onInvokeTask (core.mjs:24192:33)
at _ZoneDelegate.invokeTask (zone.js:445:64)
at Zone.runTask (zone.js:214:51)
at ZoneTask.invokeTask [as invoke] (zone.js:528:38)
at resolvePromise (zone.js:1265:35)
at resolvePromise (zone.js:1219:21)
at zone.js:1332:21
at _ZoneDelegate.invokeTask (zone.js:446:35)
at core.mjs:23891:55
at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:23891:36)
at _ZoneDelegate.invokeTask (zone.js:445:64)
at Object.onInvokeTask (core.mjs:24192:33)
at _ZoneDelegate.invokeTask (zone.js:445:64)
at Zone.runTask (zone.js:214:51)

getBinaryContent hangs out on mobile

I'm working on this project where I need to extract large zip-files (over 50 megabytes) into the mobile device.

I found this repository https://github.com/raulsouzalima/jszip-utils by @raulsouzalima which allows you to retrieve progress events from the getBinaryContent function and I noticed that when I call the getBinaryContent it hangs out around 30% when used on older devices (example iPhone 4S).

Any ideas how to get pass this issue?

Type definitions for TypeScript

Hi @Stuk ! How do you feel about TypeScript? There seems to be no types for your package. Would you mind including type definitions in the npm package? I could work on it.

jszip-utils getBinaryContent from .zip with webpack

jszip-utils getBinaryContent from .zip with webpack didn't work

GET http://localhost:8080/xxx.zip 404 (Not Found)

Uncaught Error: Ajax error for xxx.zip : 404 Not Found

how to load the static .zip file with webpack when develop

Vue local read file

In Vue project, only files under public can be read locally. Can I read a folder in another directory?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.