{"_id":"@avoylenko/multer-s3","_rev":"4-88461cb35938c8104a12e35ff0e4e975","name":"@avoylenko/multer-s3","dist-tags":{"latest":"4.0.0"},"versions":{"3.0.2":{"name":"@avoylenko/multer-s3","version":"3.0.2","keywords":["multer","s3","amazon","aws"],"author":{"name":"avoylenko"},"license":"MIT","_id":"@avoylenko/multer-s3@3.0.2","maintainers":[{"name":"avoylenko","email":"anton.voylenko@gmail.com"}],"homepage":"https://github.com/avoylenko/multer-s3#readme","bugs":{"url":"https://github.com/avoylenko/multer-s3/issues"},"dist":{"shasum":"b1b7104788fe6bad1bd26ea0adf6aad0f1f9d303","tarball":"https://registry.npmjs.org/@avoylenko/multer-s3/-/multer-s3-3.0.2.tgz","fileCount":12,"integrity":"sha512-mOgZaBuX3J+GFkCyZ3Mmn2WzfNbEp0j8pzJd9hk7ArpVp5teVIIxRI5ze2eu1XQJVT82IMDhGnSKRxJoEOwWRg==","signatures":[{"sig":"MEYCIQCwhaTpL7w8xyTSrRzIRHIFdQNYkhsSVfd+4YOBKUrXSAIhAJ8zfWppiSKZTe4xBipXqsm73C3mBiP/OfC3ul5oWmyi","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40797},"main":"index.js","engines":{"node":">= 12.0.0"},"gitHead":"299ca888381b61dcd1d5b32f77c74636b81e3517","scripts":{"test":"standard && mocha test/basic.js"},"_npmUser":{"name":"avoylenko","email":"anton.voylenko@gmail.com"},"repository":{"url":"git+https://github.com/avoylenko/multer-s3.git","type":"git"},"_npmVersion":"10.8.2","description":"Streaming multer storage engine for S3","directories":{},"_nodeVersion":"20.17.0","dependencies":{"file-type":"^20.5.0","run-parallel":"^1.2.0","@aws-sdk/lib-storage":"^3.821.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.8.2","xtend":"^4.0.2","multer":"^2.0.0","express":"^4.21.2","standard":"^17.1.2","form-data":"^4.0.2","on-finished":"^2.4.1"},"peerDependencies":{"@aws-sdk/client-s3":"^3.629.0"},"_npmOperationalInternal":{"tmp":"tmp/multer-s3_3.0.2_1748711735476_0.8206504900764549","host":"s3://npm-registry-packages-npm-production"}},"3.0.3":{"name":"@avoylenko/multer-s3","version":"3.0.3","keywords":["multer","s3","amazon","aws"],"author":{"name":"avoylenko"},"license":"MIT","_id":"@avoylenko/multer-s3@3.0.3","maintainers":[{"name":"avoylenko","email":"anton.voylenko@gmail.com"}],"homepage":"https://github.com/avoylenko/multer-s3#readme","bugs":{"url":"https://github.com/avoylenko/multer-s3/issues"},"dist":{"shasum":"05807f946903c8e7da28b0548316a07f984ae5a5","tarball":"https://registry.npmjs.org/@avoylenko/multer-s3/-/multer-s3-3.0.3.tgz","fileCount":12,"integrity":"sha512-9HRLEkFzHOHHv0ZLV0tY3+aMQzpBqlVkZx24VMaMCLu6wq/b071F5wc9UAEFLrbpYba5RlD8kVY4j9zoo9WAdQ==","signatures":[{"sig":"MEUCIFi8sanO27WnGa/ZyqLqMOW9EeohVcfwsdyS5Y8qlQlYAiEAqcd6Mkg8Bn07V1+yHuH3PUKHxu7NteMYrPfi+7fCy5U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40797},"main":"index.js","engines":{"node":">= 12.0.0"},"gitHead":"f43d38e692fb186e0d817394f5df2c009bc91dc8","scripts":{"test":"standard && mocha test/basic.js"},"_npmUser":{"name":"avoylenko","email":"anton.voylenko@gmail.com"},"repository":{"url":"git+https://github.com/avoylenko/multer-s3.git","type":"git"},"_npmVersion":"10.8.2","description":"Streaming multer storage engine for S3","directories":{},"_nodeVersion":"20.17.0","dependencies":{"file-type":"^21.0.0","run-parallel":"^1.2.0","@aws-sdk/lib-storage":"^3.850.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.8.2","xtend":"^4.0.2","multer":"^2.0.0","express":"^4.21.2","standard":"^17.1.2","form-data":"^4.0.2","on-finished":"^2.4.1"},"peerDependencies":{"@aws-sdk/client-s3":"^3.629.0"},"_npmOperationalInternal":{"tmp":"tmp/multer-s3_3.0.3_1753274676444_0.7574094597979313","host":"s3://npm-registry-packages-npm-production"}},"3.0.4":{"name":"@avoylenko/multer-s3","version":"3.0.4","keywords":["multer","s3","amazon","aws"],"author":{"name":"avoylenko"},"license":"MIT","_id":"@avoylenko/multer-s3@3.0.4","maintainers":[{"name":"avoylenko","email":"anton.voylenko@gmail.com"}],"homepage":"https://github.com/avoylenko/multer-s3#readme","bugs":{"url":"https://github.com/avoylenko/multer-s3/issues"},"dist":{"shasum":"46b116e7b8272822ff606b4b068714cea3884dfc","tarball":"https://registry.npmjs.org/@avoylenko/multer-s3/-/multer-s3-3.0.4.tgz","fileCount":12,"integrity":"sha512-uGPT6gE9aqlsPaCkgnRVPHH0W3vRijOpOSx3nnt1ScjEC9bHowJy07+YzKkNsEVefDZOVteZD2Zh+X3bh/dEtg==","signatures":[{"sig":"MEUCIA6Inewlaa7P5KAK0eslvOKKVyXMkIIScP816iB6jGGeAiEA3xW8TyCf+yqQIfLbM9sZBdal0MLcvOv8HoD2kKAyXvs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40931},"main":"index.js","engines":{"node":">= 12.0.0"},"gitHead":"f43d38e692fb186e0d817394f5df2c009bc91dc8","scripts":{"test":"standard && mocha test/basic.js"},"_npmUser":{"name":"avoylenko","email":"anton.voylenko@gmail.com"},"repository":{"url":"git+https://github.com/avoylenko/multer-s3.git","type":"git"},"_npmVersion":"10.8.2","description":"Streaming multer storage engine for S3","directories":{},"_nodeVersion":"20.17.0","dependencies":{"file-type":"^21.0.0","run-parallel":"^1.2.0","@aws-sdk/lib-storage":"^3.850.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.8.2","xtend":"^4.0.2","multer":"^2.0.0","express":"^4.21.2","standard":"^17.1.2","form-data":"^4.0.2","on-finished":"^2.4.1"},"peerDependencies":{"@aws-sdk/client-s3":"^3.629.0"},"_npmOperationalInternal":{"tmp":"tmp/multer-s3_3.0.4_1754473022451_0.10455022578025441","host":"s3://npm-registry-packages-npm-production"}},"4.0.0":{"name":"@avoylenko/multer-s3","version":"4.0.0","description":"Streaming multer storage engine for S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js","standard:fix":"standard --fix"},"engines":{"node":">= 22.0.0"},"repository":{"type":"git","url":"git+https://github.com/avoylenko/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"avoylenko"},"license":"MIT","bugs":{"url":"https://github.com/avoylenko/multer-s3/issues"},"homepage":"https://github.com/avoylenko/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.1071.0","file-type":"^22.0.1","run-parallel":"^1.2.0"},"peerDependencies":{"@aws-sdk/client-s3":"^3.1071.0"},"devDependencies":{"express":"^4.21.2","form-data":"^4.0.6","mocha":"^10.8.2","multer":"^2.2.0","on-finished":"^2.4.1","standard":"^17.1.2","xtend":"^4.0.2"},"gitHead":"f43d38e692fb186e0d817394f5df2c009bc91dc8","_id":"@avoylenko/multer-s3@4.0.0","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-mGL7UV8iD2r5eZTZp1qsCcwesAcw5neN5zj79Iguzs/cDw8EDOgao2dw27bndTU7Dm6Ui6X1GxdlCxuxVDhcPA==","shasum":"6f8a01c8f9d4cdc922ea4f091b8d8105d78f43e8","tarball":"https://registry.npmjs.org/@avoylenko/multer-s3/-/multer-s3-4.0.0.tgz","fileCount":12,"unpackedSize":40981,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH0ZaxiIzo1JyuPRO7ti1aeBFJ7/HdhGOJopqdUroyowAiAii0QT2dKbSvAecchQlfCQDrn1umla6wUNBE9JFSe7Gw=="}]},"_npmUser":{"name":"avoylenko","email":"anton.voylenko@gmail.com"},"directories":{},"maintainers":[{"name":"avoylenko","email":"anton.voylenko@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/multer-s3_4.0.0_1781802736876_0.4923357516533704"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-31T17:15:35.347Z","modified":"2026-06-18T17:12:17.153Z","3.0.2":"2025-05-31T17:15:35.686Z","3.0.3":"2025-07-23T12:44:36.671Z","3.0.4":"2025-08-06T09:37:02.642Z","4.0.0":"2026-06-18T17:12:17.035Z"},"bugs":{"url":"https://github.com/avoylenko/multer-s3/issues"},"author":{"name":"avoylenko"},"license":"MIT","homepage":"https://github.com/avoylenko/multer-s3#readme","keywords":["multer","s3","amazon","aws"],"repository":{"type":"git","url":"git+https://github.com/avoylenko/multer-s3.git"},"description":"Streaming multer storage engine for S3","maintainers":[{"name":"avoylenko","email":"anton.voylenko@gmail.com"}],"readme":"# Multer S3\n\nStreaming multer storage engine for S3.\n\nThis project is mostly an integration piece for existing code samples from Multer's [storage engine documentation](https://github.com/expressjs/multer/blob/master/StorageEngine.md) with a call to S3 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.\n\n## Installation\n\n```sh\nnpm install --save @avoylenko/multer-s3\n```\n\n## Usage\n\n```javascript\nconst { S3Client } = require('@aws-sdk/client-s3')\nconst express = require('express')\nconst multer = require('multer')\nconst multerS3 = require('@avoylenko/multer-s3')\n\nconst app = express()\n\nconst s3 = new S3Client()\n\nconst upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    metadata: function (req, file, cb) {\n      cb(null, {fieldName: file.fieldname});\n    },\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n\napp.post('/upload', upload.array('photos', 3), function(req, res, next) {\n  res.send('Successfully uploaded ' + req.files.length + ' files!')\n})\n```\n\n### File information\n\nEach file contains the following information exposed by `multer-s3`:\n\nKey | Description | Note\n--- | --- | ---\n`size` | Size of the file in bytes |\n`bucket` | The bucket used to store the file | `S3Storage`\n`key` | The name of the file | `S3Storage`\n`acl` | Access control for the file | `S3Storage`\n`contentType` | The `mimetype` used to upload the file | `S3Storage`\n`metadata` | The `metadata` object to be sent to S3 | `S3Storage`\n`location` | The S3 `url` to access the file  | `S3Storage`\n`etag` | The `etag`of the uploaded file in S3  | `S3Storage`\n`contentDisposition` | The `contentDisposition` used to upload the file | `S3Storage`\n`storageClass` | The `storageClass` to be used for the uploaded file in S3 | `S3Storage`\n`versionId` | The `versionId` is an optional param returned by S3 for versioned buckets. | `S3Storage`\n`contentEncoding` | The `contentEncoding` used to upload the file | `S3Storage`\n\n### Setting ACL\n\n[ACL values](http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) can be set by passing an optional `acl` parameter into the `multerS3` object.\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    acl: 'public-read',\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\n\nAvailable options for canned ACL.\n\nACL Option | Permissions added to ACL\n--- | ---\n`private` | Owner gets `FULL_CONTROL`. No one else has access rights (default).\n`public-read` | Owner gets `FULL_CONTROL`. The `AllUsers` group gets `READ` access.\n`public-read-write` | Owner gets `FULL_CONTROL`. The `AllUsers` group gets `READ` and `WRITE` access. Granting this on a bucket is generally not recommended.\n`aws-exec-read` | Owner gets `FULL_CONTROL`. Amazon EC2 gets `READ` access to `GET` an Amazon Machine Image (AMI) bundle from Amazon S3.\n`authenticated-read` | Owner gets `FULL_CONTROL`. The `AuthenticatedUsers` group gets `READ` access.\n`bucket-owner-read` | Object owner gets `FULL_CONTROL`. Bucket owner gets `READ` access. If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.\n`bucket-owner-full-control` | Both the object owner and the bucket owner get `FULL_CONTROL` over the object. If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.\n`log-delivery-write` | The `LogDelivery` group gets `WRITE` and `READ_ACP` permissions on the bucket. For more information on logs.\n\n## Setting Metadata\n\nThe `metadata` option is a callback that accepts the request and file, and returns a metadata object to be saved to S3.\n\nHere is an example that stores all fields in the request body as metadata, and uses an `id` param as the key: \n\n```javascript\nvar opts = {\n    s3: s3,\n    bucket: config.originalsBucket,\n    metadata: function (req, file, cb) {\n      cb(null, Object.assign({}, req.body));\n    },\n    key: function (req, file, cb) {\n      cb(null, req.params.id + \".jpg\");\n    }\n  };\n```\n\n## Setting Cache-Control header\n\nThe 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.\n\nHere is an example that will tell browsers and CDNs to cache the file for one year:\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    cacheControl: 'max-age=31536000',\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\n\n## Setting Custom Content-Type\n\nThe 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.\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    contentType: multerS3.AUTO_CONTENT_TYPE,\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\nYou may also use a function as the `contentType`, which should be of the form `function(req, file, cb)`.\n\n## Setting StorageClass\n\n[storageClass values](https://aws.amazon.com/s3/storage-classes/) can be set by passing an optional `storageClass` parameter into the `multerS3` object.\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    acl: 'public-read',\n    storageClass: 'REDUCED_REDUNDANCY',\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\n\n## Setting Content-Disposition\n\nThe optional `contentDisposition` option can be used to set the `Content-Disposition` header for the uploaded file. By default, the `contentDisposition` isn't forwarded. As an example below, using the value `attachment` forces the browser to download the uploaded file instead of trying to open it.\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    acl: 'public-read',\n    contentDisposition: 'attachment',\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\n\n## Using Server-Side Encryption\n\n*An overview of S3's server-side encryption can be found in the [S3 Docs] (http://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html); be advised that customer-managed keys (SSE-C) is not implemented at this time.*\n\nYou may use the S3 server-side encryption functionality via the optional `serverSideEncryption` and `sseKmsKeyId` parameters. Full documentation of these parameters in relation to the S3 API can be found [here] (http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property) and [here] (http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html). \n\n`serverSideEncryption` has two valid values: 'AES256' and 'aws:kms'. 'AES256' utilizes the S3-managed key system, while 'aws:kms' utilizes the AWS KMS system and accepts the optional `sseKmsKeyId` parameter to specify the key ID of the key you wish to use. Leaving `sseKmsKeyId` blank when 'aws:kms' is specified will use the default KMS key. **Note:** *You must instantiate the S3 instance with `signatureVersion: 'v4'` in order to use KMS-managed keys [[Docs]] (http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version), and the specified key must be in the same AWS region as the S3 bucket used.*\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    acl: 'authenticated-read',\n    contentDisposition: 'attachment',\n    serverSideEncryption: 'AES256',\n    key: function(req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\n\n## Setting Content-Encoding\n\nThe optional `contentEncoding` option can be used to set the `Content-Encoding` header for the uploaded file. By default, the `contentEncoding` isn't forwarded. As an example below, using the value `gzip`, a file can be uploaded as a gzip file - and when it is downloaded, the browser will uncompress it automatically.\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    acl: 'public-read',\n    contentEncoding: 'gzip',\n    key: function (req, file, cb) {\n      cb(null, Date.now().toString())\n    }\n  })\n})\n```\nYou may also use a function as the `contentEncoding`, which should be of the form `function(req, file, cb)`.\n\n## Testing\n\nThe tests mock all access to S3 and can be run completely offline.\n\n```sh\nnpm test\n```\n","readmeFilename":"README.md"}