diff options
| author | Pitu <[email protected]> | 2018-09-18 03:34:00 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-18 03:34:00 -0300 |
| commit | 4b2b02110b457d8ebeee78e1bdf99eb0660d0626 (patch) | |
| tree | a6e30208b61e3927c1681c7006241cd0d837de89 /src/api/utils | |
| parent | Stupid hash was working, the size changes for some reason when uploading (diff) | |
| download | host.fuwn.me-4b2b02110b457d8ebeee78e1bdf99eb0660d0626.tar.xz host.fuwn.me-4b2b02110b457d8ebeee78e1bdf99eb0660d0626.zip | |
We can now download albums yayyyy
Diffstat (limited to 'src/api/utils')
| -rw-r--r-- | src/api/utils/Util.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js index 617b38f..52cfb03 100644 --- a/src/api/utils/Util.js +++ b/src/api/utils/Util.js @@ -9,6 +9,7 @@ const log = require('../utils/Log'); const crypto = require('crypto'); const sharp = require('sharp'); const ffmpeg = require('fluent-ffmpeg'); +const Zip = require('adm-zip'); const imageExtensions = ['.jpg', '.jpeg', '.bmp', '.gif', '.png', '.webp']; const videoExtensions = ['.webm', '.mp4', '.wmv', '.avi', '.mov']; @@ -183,6 +184,18 @@ class Util { return user; }); } + + static createZip(files, album) { + try { + const zip = new Zip(); + for (const file of files) { + zip.addLocalFile(path.join(__dirname, '..', '..', '..', config.uploads.uploadFolder, file)); + } + zip.writeZip(path.join(__dirname, '..', '..', '..', config.uploads.uploadFolder, 'zips', `${album.userId}-${album.id}.zip`)); + } catch (error) { + log.error(error); + } + } } module.exports = Util; |