@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.
@@ -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 = await Promise.all(
397
- files.map(async dir => {
398
- const filepath = path.resolve(tmpPath, dir);
399
- const filename = path.basename(dir);
400
- const fileStream = fs.createReadStream(filepath);
401
-
402
- const mimetype = MimeTypes.lookup(filepath) || 'application/octet-stream';
403
- const file = await uploadToFileSystem({
404
- file: {
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
- namespace
412
- });
413
- return {
414
- dir,
415
- file
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-file-manager",
3
- "version": "3.0.0",
3
+ "version": "3.0.1-alpha.0",
4
4
  "description": "用于管理静态文件上传查看等",
5
5
  "main": "index.js",
6
6
  "scripts": {