Skip to content

Zipping file input (multiple files) and sending as formData #42

Answered by 101arrowz
ryanwinchester asked this question in Q&A
Discussion options

You must be logged in to vote

Looking at the code you provided, each individual file has its own pre-signed URL and fields that need to go with it. If you have a single URL to upload to, it'll be one of the following (depending on how much you care about compatibility with old browsers):

// If you use a transpiler like Babel, this works in even IE11
const zipOut = [];
const zipFile = new fflate.Zip();
zipFile.ondata = (err, dat, final) => {
  if (err) throw err;
  zipOut.push(dat);
  if (final) {
    const blob = new Blob(zipOut, { type: 'application/zip' });
    // Do whatever you need to upload here
  }
}

const ALREADY_COMPRESSED = [
  'zip', 'gz', 'png', 'jpg', 'jpeg', 'pdf', 'doc', 'docx',
  'ppt', 'pptx', 'xls', '…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ryanwinchester
Comment options

@ryanwinchester
Comment options

@ryanwinchester
Comment options

@101arrowz
Comment options

Answer selected by ryanwinchester
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants