@servable/parse-server-engine
Version:
Servable Parse Server Engine
29 lines (24 loc) • 655 B
JavaScript
import * as Minio from 'minio'
import multerMinIOStorage from 'multer-minio-storage'
export default ({ bucketName, endPoint,
accessKey,
secretKey, nameAdapter }) => {
const minioClient = new Minio.Client({
endPoint,
accessKey,
secretKey,
})
const storage = multerMinIOStorage.default({
minioClient: minioClient,
bucket: bucketName,
metadata: function (req, file, cb) {
cb(null, { fieldName: file.fieldname })
},
key: async function (req, file, cb) {
// cb(null, Date.now().toString())
const name = await nameAdapter({ file, request: req })
cb(null, name)
}
})
return storage
}