feat: added file hashing

pull/243/head
Josh Moore 11 months ago
parent f245f06647
commit c9905eb127

@ -1,6 +1,7 @@
import fs from 'fs-extra';
import bb from 'express-busboy';
import { Router } from 'express';
import crypto from 'crypto';
import { log } from '../log';
import { UserConfig } from '../UserConfig';
import { random } from '../generators';
@ -51,6 +52,9 @@ router.post('/', async (req, res) => {
// Get the file size
const fileSize = (await fs.stat(bbFile.file)).size;
// Get the hash
const sha256 = crypto.createHash('sha256').update(await fs.readFile(bbFile.file)).digest('base64');
// * Move the file
if (!s3) await fs.move(bbFile.file, destination);
else await uploadFileS3(await fs.readFile(bbFile.file), bbFile.mimetype, fileKey);

Loading…
Cancel
Save