Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project dead? #22

Open
hood opened this issue Apr 22, 2020 · 9 comments
Open

Project dead? #22

hood opened this issue Apr 22, 2020 · 9 comments

Comments

@hood
Copy link

hood commented Apr 22, 2020

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.

@alexandre-steinberg
Copy link
Collaborator

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
Copy link
Collaborator

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.

@vasilenka
Copy link

vasilenka commented Jun 8, 2020

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?

@alexandre-steinberg
Copy link
Collaborator

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?

@vasilenka
Copy link

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)

@intelivitadeveloper
Copy link

Facing same issue, any update on this?

@alexandre-steinberg
Copy link
Collaborator

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

Have fun!

@intelivitadeveloper
Copy link

Thanks @alexandre-steinberg !
Now its working fine.

@vasilenka
Copy link

@alexandre-steinberg Thank you so much sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants