multer-google-storage icon indicating copy to clipboard operation
multer-google-storage copied to clipboard

Project dead?

Open hood opened this issue 4 years ago • 9 comments

Is this project still being worked on? If not, I'd like to fork it and create a new package picking where this left off.

hood avatar Apr 22 '20 09:04 hood

Hello, I've just updated this project and submitted a pull request about 10 days ago.

There's no answer by now.

Meanwhile I've added some new features I needed for a project. I'm considering release a new package today or tomorrow. You're welcome to contribute!

alexandre-steinberg avatar Apr 26 '20 16:04 alexandre-steinberg

The fork is available as multer-cloud-storage and is updated up to Google Cloud Storage's API v5.0.1, released some days ago.

The only drawback is that it supports only node>=10.

alexandre-steinberg avatar May 25 '20 16:05 alexandre-steinberg

Hello @alexandre-steinberg, your fork works great man. Thank you.

But I've some issues when uploading multiple files using .array() or .any(). The files successfully uploaded to google cloud storage, but the returning path and filename on req.files object contain the same string for all the files uploaded.

Here's the result when I tried to log the req.files:

{
    fieldname: 'post',
    originalname: 'claim-email.png',
    filename: '1591658243037-ce-after-event.pdf',
    path: 'post/1591658243037-ce-after-event.pdf',
    uri: '.../post/1591658243037-ce-after-event.pdf',
    linkUrl: '.../post/1591658243037-ce-after-event.pdf'
},
{
    fieldname: 'post',
    originalname: 'ce-after-event.pdf',
    filename: '1591658243037-ce-after-event.pdf',
    path: 'post/1591658243037-ce-after-event.pdf',
    uri: '.../post/1591658243037-ce-after-event.pdf',
    linkUrl: '.../post/1591658243037-ce-after-event.pdf'
}

Any idea how I can fix that?

vasilenka avatar Jun 08 '20 23:06 vasilenka

I'll check it. In meantime, could you send some details as how are calling multer and configuring the storage engine? Are you passing any custom function for nameing or just working with the defaults?

alexandre-steinberg avatar Jun 09 '20 22:06 alexandre-steinberg

Thank you for the response man.

Yes, I did have a custom function for naming the files. For now, I've got a workaround by using req.file.selfLink value and process it to get the filename returned by multer.

Here's my config:

import multerGcs from 'multer-cloud-storage'

export const fileHandler = multer({
  storage: new multerGcs({
    keyFilename: path.join(__dirname, '../../../keyfile.json'),
    projectId: 'project-id',
    bucket: 'bucketname',
    acl: 'publicRead',
    destination: 'regulasi/',
    filename: (req, file, cb) => cb(null, `${Date.now()}-${file.originalname}`)
  })
})

export const handleUpload = (req, res) => {
	console.log(req.files)

	res.json({files: req.files})
}

And here's how I called the function:

router.post('/file', fileHandler.array('regulasi'), handleUpload)

vasilenka avatar Jun 10 '20 07:06 vasilenka

Facing same issue, any update on this?

intelivitadeveloper avatar Jun 23 '20 07:06 intelivitadeveloper

Fixed on v2.3.0. All packages were also updated, including Google API to v5.1.1.

Have fun!

alexandre-steinberg avatar Jun 24 '20 00:06 alexandre-steinberg

Thanks @alexandre-steinberg ! Now its working fine.

intelivitadeveloper avatar Jul 01 '20 12:07 intelivitadeveloper

@alexandre-steinberg Thank you so much sir!

vasilenka avatar Jul 19 '20 19:07 vasilenka