1

I'm using multer s3 to upload to digital ocean space. I'm sending a zip file which I want to be unzipped before it gets uploaded to space. How do I unzip the file before uploading it to multer?

Edit: The zip file has multiple folders and multiple files in it

I've created till the part where I can upload a zip file

const spacesEndpoint = new AWS.Endpoint('sgp1.digitaloceanspaces.com');
const s3 = new AWS.S3({
  endpoint: spacesEndpoint,
  accessKeyId: process.env.SPACES_ACCESS_KEY_ID,
  secretAccessKey: process.env.SPACES_ACCESS_KEY,
});

const upload = multer({
  storage: multerS3({
    s3,
    bucket: "my-bucket"
    },
    acl: 'public-read',
    key: function (req, file, cb) {
      cb(null, file.originalname);
    },
  }),
});

router.post(
  '/upload',
  upload.fields([{ name: 'name' }, { name: 'data' }]),
  async function (req, res, next) {
      res.send('status ok');
  },
);

0 Answers0