Skip to content

Commit

Permalink
Update formidable 3.2.4 => 3.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin committed Jul 6, 2024
1 parent a5fea28 commit 891697f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"docker-secret": "1.1.2",
"express": "4.19.2",
"express-urlrewrite": "1.2.0",
"formidable": "3.2.4",
"formidable": "3.5.1",
"gm": "1.23.1",
"got": "11.8.5",
"http-proxy-middleware": "0.20.0",
Expand Down
16 changes: 8 additions & 8 deletions uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ export function configure(startStamp) {

class FileInfo {
constructor(file, targetDir, nameLen, dirDepth) {
this.name = file.name;
this.name = file.originalFilename;
this.size = file.size;
this.mime = file.type;
this.mime = file.mimetype;
this.path = file.filepath;

this.createFileName(targetDir, nameLen, dirDepth);
}
Expand Down Expand Up @@ -193,7 +194,7 @@ export function configure(startStamp) {
}

const postHandler = (req, res) => {
const form = new formidable.IncomingForm();
const form = formidable({uploadDir: incomeDir});

Check failure on line 197 in uploader.js

View workflow job for this annotation

GitHub Actions / build

A space is required after '{'

Check failure on line 197 in uploader.js

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'
const isAvatar = req.url === '/uploadava';
const maxPostSize = isAvatar ? maxAvaPostSize : maxPhotoPostSize;
const targetDir = isAvatar ? targetDirAvatar : targetDirPhoto;
Expand All @@ -210,22 +211,21 @@ export function configure(startStamp) {
tooBigPostDestroy(req, isAvatar, 0, contentLength);
}

form.uploadDir = incomeDir;
form
.on('fileBegin', (name, file) => {
tmpFiles.push(file.path);
tmpFiles.push(file.filepath);

const fileInfo = new FileInfo(file, targetDir, isAvatar ? 10 : 18, isAvatar ? 2 : 3);

map[path.basename(file.path)] = fileInfo;
map[path.basename(file.filepath)] = fileInfo;
files.push(fileInfo);
})
.on('file', (name, file) => {
const fileInfo = map[path.basename(file.path)];
const fileInfo = map[path.basename(file.filepath)];

fileInfo.size = file.size;
fileInfo.path = path.join(incomeDir, fileInfo.file);
mv(file.path, fileInfo.path, { clobber: false }, err => {
mv(file.filepath, fileInfo.path, { clobber: false }, err => {
if (err) {
logger.error('MV error:', err);
}
Expand Down

0 comments on commit 891697f

Please sign in to comment.