@kne/fastify-file-manager 3.0.0 → 3.0.1-alpha.0
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/libs/services/file-record.js +23 -22
- package/package.json +1 -1
|
@@ -392,30 +392,31 @@ module.exports = fp(async (fastify, fastifyOptions) => {
|
|
|
392
392
|
cwd: tmpPath,
|
|
393
393
|
nodir: true
|
|
394
394
|
});
|
|
395
|
+
console.log('---->1:', files);
|
|
395
396
|
//将文件上传到文件系统
|
|
396
|
-
const fileList =
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
filename,
|
|
406
|
-
mimetype,
|
|
407
|
-
encoding: 'binary',
|
|
408
|
-
file: fileStream
|
|
409
|
-
},
|
|
397
|
+
const fileList = [];
|
|
398
|
+
for (let dir of files) {
|
|
399
|
+
const filepath = path.resolve(tmpPath, dir);
|
|
400
|
+
const filename = path.basename(dir);
|
|
401
|
+
const fileStream = fs.createReadStream(filepath);
|
|
402
|
+
const mimetype = MimeTypes.lookup(filepath) || 'application/octet-stream';
|
|
403
|
+
console.log(filename, mimetype);
|
|
404
|
+
const file = await uploadToFileSystem({
|
|
405
|
+
file: {
|
|
410
406
|
filename,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
})
|
|
418
|
-
|
|
407
|
+
mimetype,
|
|
408
|
+
encoding: 'binary',
|
|
409
|
+
file: fileStream
|
|
410
|
+
},
|
|
411
|
+
filename,
|
|
412
|
+
namespace
|
|
413
|
+
});
|
|
414
|
+
console.log('---->2:', dir, file);
|
|
415
|
+
fileList.push({
|
|
416
|
+
dir,
|
|
417
|
+
file
|
|
418
|
+
});
|
|
419
|
+
}
|
|
419
420
|
fs.remove(tmpPath).catch(console.error);
|
|
420
421
|
return fileList;
|
|
421
422
|
};
|