multer-s3 icon indicating copy to clipboard operation
multer-s3 copied to clipboard

package dosent work for minio s3 compatible

Open m0x61h0x64i opened this issue 2 years ago • 4 comments

as you know minio is also a s3 compatible so i used minio configuration like the following to create a s3 config :

const Minio = require('minio')
const s3= new Minio.Client({
    endPoint,
    useSSL: true,
    accessKey,
    secretKey
})
module.exports = s3

and then i used this configuration in the multer-s3 to create a storage :

const s3 = require('../../configs/up.config')
const multer = require('multer')
const multerS3 = require('multer-s3')

const storage = multerS3({
    s3,
    bucket: 'test',
    acl: 'public-read',
    contentType: multerS3.AUTO_CONTENT_TYPE,
    metadata: function (req, file, cb) {
      cb(null, {fieldName: file.fieldname});
    },
    key: function (req, file, cb) {
      cb(null, Date.now().toString())
    }
})
const upload = multer({ storage })
module.exports = upload.single('image')

but it dosent work and throws an error :

C:\Users\user\Desktop\example\node_modules\multer-s3\index.js:210
    var upload = this.s3.upload(params)
                         ^

TypeError: this.s3.upload is not a function
    at S3Storage.<anonymous> (C:\Users\user\Desktop\example\node_modules\multer-s3\index.js:210:26)
    at C:\Users\user\Desktop\example\node_modules\multer-s3\index.js:84:10

m0x61h0x64i avatar Oct 15 '22 06:10 m0x61h0x64i

Please share information about the file that is calling this module

TREER00T avatar Oct 15 '22 20:10 TREER00T

Please share information about the file that is calling this module

here is the route & controller :

const upload = require('../middleware/upload.js')
const app = require('express')()

app.get('/', upload, (req, res) => {
    console.log(req.file)
})

m0x61h0x64i avatar Oct 16 '22 04:10 m0x61h0x64i

Have you used the upload module in this way?

const upload = require('../middleware/upload.js')
const app = require('express')()

app.get('/', (req, res) => {
    upload(req, res , (req, res) => {
       console.log(req.file)
    })
})

TREER00T avatar Oct 16 '22 06:10 TREER00T

Have you used the upload module in this way?

const upload = require('../middleware/upload.js')
const app = require('express')()

app.get('/', (req, res) => {
    upload(req, res , (req, res) => {
       console.log(req.file)
    })
})

yes, that didnt help me to solve the issue.

m0x61h0x64i avatar Oct 16 '22 08:10 m0x61h0x64i

I'm afraid that we cannot help you with Minio compatibility since that isn't something we support officially...

Per your error:

var upload = this.s3.upload(params) TypeError: this.s3.upload is not a function

It looks like the thing you passed in as s3 doesn't have an upload function?

LinusU avatar Nov 01 '22 10:11 LinusU