NodeJS

Multer S3 – Streaming multer storage engine for AWS S3.

This project is mostly an integration piece for existing code samples from Multer’s storage engine documentation with s3fs as the substitution piece for file system. Existing solutions I found required buffering the multipart uploads into the actual filesystem which is difficult to scale.

Installation

npm install –save multer-s3

Usage

The optional cacheControl option sets the Cache-Control HTTP header that will be sent if you’re serving the files directly from S3. You can pass either a string or a function that returns a string.


Setting Custom Content-Type

The optional contentType option can be used to set Content/mime type of the file. By default the content type is set to application/octet-stream. If you want multer-s3 to automatically find the content-type of the file, use the multerS3.AUTO_CONTENT_TYPE constant. Here is an example that will detect the content type of the file being uploaded.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *