question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modify files before storing them

See original GitHub issue

It would be useful to have the ability to modify files as they are uploaded. A simple example would be resizing an image using gd.

My initial thoughts are the fileFilter function could return the file as the second argument rather than a boolean. That way it could be manipulated in the fileFilter function and then be passed on to be stored, or dropped if false was passed instead of the file.

https://github.com/expressjs/multer/blob/master/lib/make-middleware.js#L94

This would be more useful when using an external storage engine such as S3 as you wouldn’t have to upload -> download -> edit -> re-upload.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:3
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
LinusUcommented, Jun 22, 2016

@wesleytodd Maybe it’s better to make the transformFile option belong on the global multer instance? That way we don’t have to implement it in every storage module.

Also, I think that transformFile should be a function that takes (req, file, cb) that calls the cb with a replacement stream

2reactions
jonchurchcommented, Jan 25, 2020

Current PR that would allow this is https://github.com/expressjs/multer/pull/399

Read more comments on GitHub >

github_iconTop Results From Across the Web

View and modify files and folders in Files on iPhone
Browse and open files and folders · Tap Browse at the bottom of the screen, then tap an item on the Browse screen....
Read more >
ruby on rails - active storage - how to modify file and resave it
I am trying to modify uploaded file once it is uploaded but I want to modify it (e.g. do some imagemagick operations on...
Read more >
Best Practice: Organizing Video Files for Editing - FXhome
Cloud Storage can be a good backup option you can access online from anywhere. Often best for use during a project to transfer...
Read more >
Change the default storage location for backup files
Click File > Options > Save & Backup. Under Save, in the Paths list, click Backup Folder, and then click Modify. In the...
Read more >
Editing settings for your SMB file share - AWS Storage Gateway
You cannot edit an existing file share to point to a new bucket or access point, or to modify the VPC endpoint settings....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found