@domain.js/main 1.1.3 → 1.1.4
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/http/utils.js +16 -5
- package/package.json +1 -1
package/dist/http/utils.js
CHANGED
|
@@ -158,7 +158,20 @@ function Utils(cnf) {
|
|
|
158
158
|
for await (const part of parts) {
|
|
159
159
|
if (part.type === "file") {
|
|
160
160
|
const saved = await RestifyFileConvertUploadFiles(part);
|
|
161
|
-
|
|
161
|
+
if (!saved)
|
|
162
|
+
continue;
|
|
163
|
+
const [field, file] = saved;
|
|
164
|
+
if (files[field]) {
|
|
165
|
+
if (Array.isArray(files[field])) {
|
|
166
|
+
files[field].push(file);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
files[field] = [files[field], file];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
files[field] = file;
|
|
174
|
+
}
|
|
162
175
|
}
|
|
163
176
|
else if (part.type === "field") {
|
|
164
177
|
const key = part.fieldname;
|
|
@@ -237,8 +250,7 @@ function Utils(cnf) {
|
|
|
237
250
|
};
|
|
238
251
|
async function RestifyFileConvertUploadFiles(files) {
|
|
239
252
|
if (!files)
|
|
240
|
-
return
|
|
241
|
-
const result = {};
|
|
253
|
+
return;
|
|
242
254
|
// 生成临时文件路径
|
|
243
255
|
const tempFileName = `${crypto.randomBytes(16).toString("hex")}_${files.filename}`;
|
|
244
256
|
const tempFilePath = `${TMPDIR}/${tempFileName}`;
|
|
@@ -261,8 +273,7 @@ function Utils(cnf) {
|
|
|
261
273
|
type: files.mimetype,
|
|
262
274
|
mtime: stats.mtime.toISOString(),
|
|
263
275
|
};
|
|
264
|
-
|
|
265
|
-
resolve(result);
|
|
276
|
+
resolve([files.fieldname, uploadFile]);
|
|
266
277
|
});
|
|
267
278
|
writeStream.on("error", (error) => {
|
|
268
279
|
reject(error);
|