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

MS Office (.xlsx, .docx) being assigned application/zip ContentType when using AUTO_CONTENT_TYPE #167

Open
globalbuild opened this issue Apr 19, 2022 · 2 comments

Comments

@globalbuild
Copy link

const multerStorage = multerS3({ s3: s3, acl: 'public-read', contentType: multerS3.AUTO_CONTENT_TYPE, contentDisposition: 'attachment', bucket: process.env.S3_BUCKET, });

This works for all files except for MS Office, .docx, .xlsx, .pptx .... I see that you are using file-type to detect and set the proper ContentType. Is this a known issue?

@LinusU
Copy link
Collaborator

LinusU commented May 30, 2022

It seems like we just need to update the version of file-type in order to fix this...

I know that they have made a few breaking changes lately, and we are on a very old version. If anyone could find out which version we can upgrade to without breaking anything for users of this library, we could release that as 3.1.0.

Long term we could upgrade to the latest version in 4.0.0.

@oeduardomarinho
Copy link

oeduardomarinho commented Nov 22, 2022

Hello folks, I'm saying Hi from Brazil.

I used to have the same problem by here. And... I have a solution that don't need to update anything!

So, I added a property called contentDisposition to the MulterS3 construtor in my code. Like this:

module.exports = {
  configuration: multer({
    storage: multerS3({
      [...]
      contentDisposition: 'attachment', // I'm not sure if this affects this problem, but seems right to be here for me
      [...]
    }),
  })
}

Futhermore, to every S3 signing operation, it will be necessary to add this param:
ResponseContentDisposition: `attachment; filename="${key}"`, where key can be the name of the file

Ps.: I almost forgot to say that this blog made me realize what was forgetting to parametrize. The best thing is that I didn't need to change the encode of any files on my file server, they were all perfect.

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

3 participants