multermate 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +6 -5
- package/dist/esm/index.js +6 -5
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.uploadSingle = uploadSingle;
|
|
|
8
8
|
exports.uploadMultiple = uploadMultiple;
|
|
9
9
|
exports.deleteFile = deleteFile;
|
|
10
10
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
|
+
const fs_1 = require("fs");
|
|
11
12
|
const multer_1 = __importDefault(require("multer"));
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
13
14
|
const uuid_1 = require("uuid");
|
|
@@ -166,9 +167,9 @@ const configureStorage = (destination) => {
|
|
|
166
167
|
return multer_1.default.diskStorage({
|
|
167
168
|
destination: (req, file, cb) => {
|
|
168
169
|
const dir = destination || "uploads";
|
|
169
|
-
// Create directory synchronously
|
|
170
|
+
// Create directory synchronously - multer destination callback doesn't support async
|
|
170
171
|
try {
|
|
171
|
-
|
|
172
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
172
173
|
cb(null, dir);
|
|
173
174
|
}
|
|
174
175
|
catch (error) {
|
|
@@ -177,7 +178,7 @@ const configureStorage = (destination) => {
|
|
|
177
178
|
cb(null, dir);
|
|
178
179
|
}
|
|
179
180
|
else {
|
|
180
|
-
cb(new MultermateError(`Failed to create destination directory: ${dir}`, 'DESTINATION_ERROR'), '');
|
|
181
|
+
cb(new MultermateError(`Failed to create destination directory: ${dir}. Error: ${error.message}`, 'DESTINATION_ERROR'), '');
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
184
|
},
|
|
@@ -279,7 +280,7 @@ function uploadSingle(options = {}) {
|
|
|
279
280
|
return (req, res, next) => {
|
|
280
281
|
// Make sure the destination directory exists
|
|
281
282
|
try {
|
|
282
|
-
|
|
283
|
+
(0, fs_1.mkdirSync)(destination, { recursive: true });
|
|
283
284
|
}
|
|
284
285
|
catch (error) {
|
|
285
286
|
// Directory might already exist, ignore error
|
|
@@ -363,7 +364,7 @@ function uploadMultiple(options) {
|
|
|
363
364
|
return (req, res, next) => {
|
|
364
365
|
// Make sure the destination directory exists
|
|
365
366
|
try {
|
|
366
|
-
|
|
367
|
+
(0, fs_1.mkdirSync)(destination, { recursive: true });
|
|
367
368
|
}
|
|
368
369
|
catch (error) {
|
|
369
370
|
// Directory might already exist, ignore error
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
|
+
import { mkdirSync } from 'fs';
|
|
2
3
|
import multer from 'multer';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -156,9 +157,9 @@ const configureStorage = (destination) => {
|
|
|
156
157
|
return multer.diskStorage({
|
|
157
158
|
destination: (req, file, cb) => {
|
|
158
159
|
const dir = destination || "uploads";
|
|
159
|
-
// Create directory synchronously
|
|
160
|
+
// Create directory synchronously - multer destination callback doesn't support async
|
|
160
161
|
try {
|
|
161
|
-
|
|
162
|
+
mkdirSync(dir, { recursive: true });
|
|
162
163
|
cb(null, dir);
|
|
163
164
|
}
|
|
164
165
|
catch (error) {
|
|
@@ -167,7 +168,7 @@ const configureStorage = (destination) => {
|
|
|
167
168
|
cb(null, dir);
|
|
168
169
|
}
|
|
169
170
|
else {
|
|
170
|
-
cb(new MultermateError(`Failed to create destination directory: ${dir}`, 'DESTINATION_ERROR'), '');
|
|
171
|
+
cb(new MultermateError(`Failed to create destination directory: ${dir}. Error: ${error.message}`, 'DESTINATION_ERROR'), '');
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
},
|
|
@@ -269,7 +270,7 @@ export function uploadSingle(options = {}) {
|
|
|
269
270
|
return (req, res, next) => {
|
|
270
271
|
// Make sure the destination directory exists
|
|
271
272
|
try {
|
|
272
|
-
|
|
273
|
+
mkdirSync(destination, { recursive: true });
|
|
273
274
|
}
|
|
274
275
|
catch (error) {
|
|
275
276
|
// Directory might already exist, ignore error
|
|
@@ -353,7 +354,7 @@ export function uploadMultiple(options) {
|
|
|
353
354
|
return (req, res, next) => {
|
|
354
355
|
// Make sure the destination directory exists
|
|
355
356
|
try {
|
|
356
|
-
|
|
357
|
+
mkdirSync(destination, { recursive: true });
|
|
357
358
|
}
|
|
358
359
|
catch (error) {
|
|
359
360
|
// Directory might already exist, ignore error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multermate",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "A powerful and flexible file upload utility built on top of Multer with TypeScript support, comprehensive file type handling, custom error classes, and universal JavaScript module compatibility",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|