用于Multer的飞行存储器
此套件包含 Flystorage 绑定 摩尔特。 。 。 .
这使得multer可以上传到任何支持的Flystorage文件系统.
安装
安装所有需要的软件包
npm install --save @flystorage/file-storage @flystorage/multer-storage
使用量
import {FileStorage} from '@flystorage/file-storage';
import {FlystorageMulterStorageEngine} from '@flystorage/multer-storage';
import multer from 'multer';
const adapter = createYourAdapter();
const fileStorage = new FileStorage(adapter);
const storage = new FlystorageMulterStorageEngine(
uploadStorage,
async (action, _req: express.Request, file: Express.Multer.File) => {
if (action === 'handle') {
return file.originalname;
} else {
return file.destination;
}
}
);
const uploader = multer({storage});