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