change path

master
Lucas 2 years ago
parent 2994342be0
commit 17a3eb84db
  1. 9
      src/api/controllers/v1/path.controller.js

@ -137,14 +137,14 @@ exports.delete = (req, res, next) => {
return ErrorHandel(ex, req, res, next);
}
};
exports.download = (req, res, next) => {
exports.download = async (req, res, next) => {
try {
const user = req.user;
const namefile = `${user.name}-${Date.now()}.zip`;
const dir = `${storageConfig.uri}/download/${user.id}/${namefile}`;
const folder = `${storageConfig.uri}/download/${user.id}`;
deleteFolderRecursive(folder);
multer({ dest: `${dir}` });
await deleteFolderRecursive(folder);
const output = fs.createWriteStream(dir);
const archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
@ -171,7 +171,7 @@ exports.download = (req, res, next) => {
code: 0,
data: {
name: namefile,
path: `${cdnConfig.uri}/${user.id}/${namefile}`,
path: `${cdnConfig.uri}/download/${user.id}/${namefile}`,
}
});
} catch (ex) {
@ -234,6 +234,5 @@ function deleteFolderRecursive(folderPath) {
console.log('Deleted file:', currentPath);
}
});
}
}

Loading…
Cancel
Save