{"_id":"multer-s3-transform","_rev":"7-758237127e90720b6630dcac3a982069","name":"multer-s3-transform","description":"Streaming multer storage engine for AWS S3","dist-tags":{"latest":"2.10.3"},"versions":{"2.3.2":{"name":"multer-s3-transform","version":"2.3.2","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"file-type":"^3.3.0","run-parallel":"^1.1.6"},"devDependencies":{"aws-sdk":"^2.2.32","concat-stream":"^1.5.1","express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"gitHead":"c4f319372f04b80eac8b67f2290ea471da1b4b92","_id":"multer-s3-transform@2.3.2","_shasum":"0f1039aaef1327a05af262e2fc160c7a1f2bccc0","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"},"dist":{"shasum":"0f1039aaef1327a05af262e2fc160c7a1f2bccc0","tarball":"https://registry.npmjs.org/multer-s3-transform/-/multer-s3-transform-2.3.2.tgz","integrity":"sha512-ecsJYyuvRdEDwSUAZ3QBl4RdCSwP6IUGP50p38Tx79KiJ6IwmJ5tY+rQqBkRf09bcVfTaOMwqQTM0VHxyaonwQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH7pEOLI41YvHRyLl4gsUu7m4WqD0HUcg5ONdfiyDUWwAiBtXTVnHoYYc7W/N/YHeFhHXChresRLAVXUBXcQPuDvuw=="}]},"maintainers":[{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/multer-s3-transform-2.3.2.tgz_1490136366937_0.009408382698893547"},"directories":{}},"2.10.0":{"name":"multer-s3-transform","version":"2.10.0","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"mocha test/basic.js"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"file-type":"^3.3.0","is-svg":"^2.1.0","run-parallel":"^1.1.6"},"devDependencies":{"aws-sdk":"^2.2.32","concat-stream":"^1.5.1","express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"gitHead":"900804e01103a3c280f1d54814bba5892bd69354","_id":"multer-s3-transform@2.10.0","_nodeVersion":"12.16.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-ZhjLzSFain/12nbG7OqAPTqSBonJV8WTgighY/9A3f0Ui/9TNLRUtxREms8T+boZkUFXow3GUakej517TAOPgQ==","shasum":"a57a15fc9c22bf8e91da8bb73bd095c95d28a2dc","tarball":"https://registry.npmjs.org/multer-s3-transform/-/multer-s3-transform-2.10.0.tgz","fileCount":9,"unpackedSize":32455,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfs36KCRA9TVsSAnZWagAAkjUP/3fmmSaUjDpp+Ldo1uUc\nonQmM75B646jBbSykcr1xlYr/K0L0paUykjJRHb2s8wWgOtZVAvLkjJbuA6j\nH5DnkflnvR7L0IiLMbyHg9Xmlpt027ocJ3JJgpFlJmGXTfuJE0ctM4aREtj/\nrhUTMNuGdTbZaWHzPrZLIL34jxFYUzZbalF5bBBkR/wMv7g29OWEAQTJwhiq\nYlOCnKSH2OmCbelRWT1AQpy9DkEifPnnip+GLb7kyWt7Ih8m7t+x6MESn+WF\nf3PIJBnMq7b2tk/p/nB/pQCnYLJVJACtK+t/1fQeUZQj+eKsWVMc2Qh8eHGt\nKapm13plWEGiUmh3V2zmRymWJxZ1Yea50adMco4TMEv8hlFyCuOAclC771L9\nc3CejHBqV++x7Lp9kOFrzRgcm0Ubqg3pABRsY/R5BpMDPK9iIgjlqCKNT8a0\nUmUEeEKieZkWuPp6WJqqPEMFt2KrvyAIfOUAZEdNd0PRnpj9wL4NHTPSsT+g\nvyXQBC/dSsFTd0DwBThanq6ACx5/AzitDhfA9OsovANgUFbwCpf7SlDa5K/r\nJ+IvLoDFSamo2LKOOzSbtvnA+sTwlkbTvSyAAyTKcTVQflCdGERpb+APIzcM\nh8b/bPR2CqmJO9V1d22/LEyPSjPsjlvWOZlox2kBwl5N0wTZCT/Z1/2tIDhk\ns1dd\r\n=IdqV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYhdyHAEt9zwobGM8+uZzWlXMjCz4zJYWlZA2D9vERqgIgGVXK9kGTD0hKH42wruBn+U2MKySzGl5fJdTKJ8l/MVU="}]},"_npmUser":{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"},"directories":{},"maintainers":[{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-s3-transform_2.10.0_1605598858150_0.22782492526958475"},"_hasShrinkwrap":false},"2.10.1":{"name":"multer-s3-transform","version":"2.10.1","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"mocha test/basic.js"},"repository":{"type":"git","url":"git+https://github.com/tehkaiyu/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"tehkaiyu"},"license":"MIT","bugs":{"url":"https://github.com/tehkaiyu/multer-s3/issues"},"homepage":"https://github.com/tehkaiyu/multer-s3#readme","dependencies":{"file-type":"^3.3.0","is-svg":"^2.1.0","run-parallel":"^1.1.6"},"devDependencies":{"aws-sdk":"^2.2.32","concat-stream":"^1.5.1","express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"gitHead":"d5d408cc7f8c8775919bbe9aefaa6c759372e7d6","_id":"multer-s3-transform@2.10.1","_nodeVersion":"12.16.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-GvSz70IBVY3wUlV2qPyXKVeyaBxvbMrSoIu0mPZJOV1qwuo6oSx8PFB7Tugb3m+XBhYHSRqqpOIA5BP2/w7wiA==","shasum":"5cb6ef943ab7bd88a8373fd8ce30818abe40041f","tarball":"https://registry.npmjs.org/multer-s3-transform/-/multer-s3-transform-2.10.1.tgz","fileCount":9,"unpackedSize":32463,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfs3+5CRA9TVsSAnZWagAAh4UP/jn/4zie4fHBFuaJHUc9\n1e9AVkBfCGdKvhcfrd0CrW3ONTMc3ZUI9GNbAJko+CAePGY0RZEdV8T7m/5A\nln0zeAUxyRrJKaGFc3Ts3K+ZEQivV8Yn6jLpyZ8gHJp9ySnXLbs3f6vcZbik\n98pEEHWt7HcXQXuhOwUxpcJCALEk85FRFBPPufdw6G3VBYKDPa8usAj4ehZv\nbWvsbliUL9yLsGtUsA0QJQ7roWwhbMDNQSZ8evBzDFiRKmy9DKqRbRGrIpZu\ngXAcxVjBNAfxomaQ6mjeSayHgAEliBtolSHuMfpZfEePu5iTi8neUe78+zjr\nWYZ3v4+gD7HQMrQr6jiPKlOwLJE5OgxCgvOEJml1nMteikL4v/GkJNm1Kbhl\n67XfBHu6WSZSL0IItfE0ztY5lCdPMfIHwVi/oys/t+sgzav9JTYHVG6DR0mO\nOWYYr1bKxFu4xMK0FR1ugESiGawa3qRGgQitB3JN/zApDRzJYyzepEy2Kl1M\nEJdrc2Oy++crLvVd4u/mVoFo+5CNWv9u7oooOvquK2FilJnY6jjZQhlDHj5J\n8MHYn6ghMBcsM6aPT0/ScipjEtu0Xhv5QRuXLqjg/b4keRPTL4PRUiiN8dKf\nIXmIaF1B5vyKra2LDHo4zaJnJU3DugdHLfTj2M+aw8HJwpku6pc7jBaS8v2E\nFb1H\r\n=4xnp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBsvkK2wVyfLOjFLMhaSOjDs85Ar0N7JS+svkZIvofzgIgLiE5thYvt5X2h1Kaika1HcHHhAN11nYFuK2reGVK0J8="}]},"_npmUser":{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"},"directories":{},"maintainers":[{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-s3-transform_2.10.1_1605599161156_0.35290023985044483"},"_hasShrinkwrap":false},"2.10.2":{"name":"multer-s3-transform","version":"2.10.2","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"mocha test/basic.js"},"repository":{"type":"git","url":"git+https://github.com/tehkaiyu/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/tehkaiyu/multer-s3#readme","dependencies":{"file-type":"^3.3.0","is-svg":"^2.1.0","run-parallel":"^1.1.6"},"devDependencies":{"aws-sdk":"^2.2.32","concat-stream":"^1.5.1","express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"gitHead":"5c7d100d222657d8ce9dbead9ed64e55d48c25e1","_id":"multer-s3-transform@2.10.2","_nodeVersion":"12.16.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-+Y6OyOgT33G1H4H29ozaHe7tDSlEQhA9uKxQlIl9QJoKUE0pQ3m/2KdmpVzGyFr8SPcUNlWRKtkUw8ggHir72w==","shasum":"d271b5a068195a3721918906b9b82bd9f4e50ad3","tarball":"https://registry.npmjs.org/multer-s3-transform/-/multer-s3-transform-2.10.2.tgz","fileCount":9,"unpackedSize":32459,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfs4CVCRA9TVsSAnZWagAA2KsP/jLRFIQMPHE7SFUhkO5I\nh00Rb6/SyLyld5iJJbithl0vDVIdFcpMdK9FenGfAmVABS4tD+9GwEbIZb/X\nxHfZvERPU7oWd/PgDyT2jwb5+qzrQBSe6DR8Z/b3Tt3O4UdxepeH8xGN5fTW\nU+cLV75Zn2Eh4438Clzfx93b4/w2WFnUuGEcfO3F+N2JkbTbExZAfN8hGyST\nh56ESwKpnryNwHsxTl1pAdI6+BrtRWn+n7Y1ZcqUil4xFjDlNiGgyivyWBYU\ncOYmTpMJy77D75cIbD7fo0jMmRjEDLRXjK494utVaIR3U5YQtVGWyBgRMLnN\noJWBB08cjyMzj6CfpAwmDAr3Y99ThxVvmUiCjH39+4jlQzGRqoPRnZbYpC6+\naedi590lDCycJ26kyw5N9b+hozh4ba8bJDh6ldYyaYWQK0ttEL95Re+n7fzG\nAPpEB5RsGJ+8ltPtkHJ4gYWiCBK8oMGfdDQYZQJ/ttCFhZclwt6l6Iiehw5k\nbGkXNDrOTt4vB5zjNxsIjoAUkuMg8oXxDGtXBobWOu+04psm+uMh0AqWrQO4\npw/9Jf2bmN4T0BvDA5DzR51jU8NngXZ5ccuIKv2RJYepNr3GHRsSOvrJGjOt\nMDtISeee4cglflgNXFA3fDgneu34WW2Ue11EOMu+sY9P6dCOpFfMCPi1AUCb\n7RTt\r\n=GTFc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDA6TxQqvpKVexBZze5u7vusk2k3G7q77o9cFyHxIKyjwIgZXkz//NtobCE/dUoeP5wlc1j9aXw3IuIUajig//89x8="}]},"_npmUser":{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"},"directories":{},"maintainers":[{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-s3-transform_2.10.2_1605599381386_0.4959631459721212"},"_hasShrinkwrap":false},"2.10.3":{"name":"multer-s3-transform","version":"2.10.3","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"mocha test/basic.js"},"repository":{"type":"git","url":"git+https://github.com/tehkaiyu/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/tehkaiyu/multer-s3#readme","dependencies":{"file-type":"^3.3.0","is-svg":"^2.1.0","run-parallel":"^1.1.6"},"devDependencies":{"aws-sdk":"^2.2.32","concat-stream":"^1.5.1","express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","xtend":"^4.0.1"},"gitHead":"d3bb819062958b99d7edd347f3c5588fb506763d","_id":"multer-s3-transform@2.10.3","_nodeVersion":"12.16.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-Mm31JEFDL+7q7x7JN9HHFVohykUNLAinbImsHPYZL9+tXq8YoW1HyIJpaua/TVQqJ45I6So2S4M1lhdtrdq33w==","shasum":"f915462edfe87138b3e54e6793d1fe1030f58eea","tarball":"https://registry.npmjs.org/multer-s3-transform/-/multer-s3-transform-2.10.3.tgz","fileCount":9,"unpackedSize":32660,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfs8s5CRA9TVsSAnZWagAALVUP/1v2seyUoxcugrRc4RCv\nyGAqVcX17NkbTikfOC7rGbNAHkotq8Vml1eciKb6Is7kGoScWZkuklSw103H\nxjXeb8dSbQTSttfjYl+5no5bh1NUOTzniGTEtF9k82Da9kg2a/Db7xeSN5lC\nYEtJ9tRIk2jIzUAJRJmzFcLQEFePED4IQZVZFzrRYhh3YyR9+9mG9PbrQkpE\nfnNzTuHVB7QoD903Qo1EfnkP21jP5JKtMVFw1QPyevHgn8XzG6XEsmb/QLJC\n7SeS9pQ/RVelB9H47Nm19ueEh/WHXBEttYODbFa6SnOMaJCxTgcon5OoAb8Q\nflSLU4cvA5+nGHaeJUFupCD3g58fHzH9gnpkOfHTZ1rPo83grIB8eTZELqNN\nn6dnt5tO22qWpgZBv4BgHX1XHKNuG5olkMuLhWySSE6FaNTCTvabolq5C8NG\njhfoMiZ8o6RHycSyuxBPJdn7ZgHvCUfpqwk+qHxZA0zKHFQbWwaMIWI5T/Um\nhSU1MmWozWOU6pMxIPRPKdLun8NprKWihn1hXpW4HPs/lShSA6+vDvHzUEgG\ni0VmYzsbf5wNaPqV+7wq0C+ma2E4IgkMQytZ0i+yF8C6HipmHZvfpnenjH61\n1NQoasmElUvRKVTO5o2fAatbvYa7qm+2oUDP1Fzk4U7xuoeRGw6PZuHfbuiD\nZE27\r\n=tJeQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDcZRQbDuEpRkahmLRaJd7XRQtxj68xConnIBwL+2iBsgIhAPPWUKg6hjEx8oORNQ80rqRZzWk5vV+N+HKhTh9VOoTt"}]},"_npmUser":{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"},"directories":{},"maintainers":[{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-s3-transform_2.10.3_1605618488714_0.760590301327067"},"_hasShrinkwrap":false}},"readme":"# Multer S3 Transform\n\n> This is a fork of [Multer S3](https://github.com/badunk/multer-s3), kept up to date, with the added [Transform](https://github.com/tehkaiyu/multer-s3#transforming-files-before-upload) property.\n\nStreaming multer storage engine for AWS 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 [s3fs](https://github.com/RiptideElements/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.\n\n## Installation\n\n```sh\nnpm install --save multer-s3-transform\n```\n\n## Usage\n\n```javascript\nvar aws = require('aws-sdk')\nvar express = require('express')\nvar multer = require('multer')\nvar multerS3 = require('multer-s3-transform')\n\nvar app = express()\nvar s3 = new aws.S3({ /* ... */ })\n\nvar 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\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## Transforming Files Before Upload\n\nThe optional `shouldTransform` option tells multer whether it should transform the file before it is uploaded. By default, it is set to `false`. If set to `true`, `transforms` option must be added, which tells how to transform the file. `transforms` option should be an `Array`, containing objects with can have properties `id`, `key` and `transform`.\n\n```javascript\nvar upload = multer({\n  storage: multerS3({\n    s3: s3,\n    bucket: 'some-bucket',\n    shouldTransform: function (req, file, cb) {\n      cb(null, /^image/i.test(file.mimetype))\n    },\n    transforms: [{\n      id: 'original',\n      key: function (req, file, cb) {\n        cb(null, 'image-original.jpg')\n      },\n      transform: function (req, file, cb) {\n        cb(null, sharp().jpg())\n      }\n    }, {\n      id: 'thumbnail',\n      key: function (req, file, cb) {\n        cb(null, 'image-thumbnail.jpg')\n      },\n      transform: function (req, file, cb) {\n        cb(null, sharp().resize(100, 100).jpg())\n      }\n    }]\n  })\n})\n```\nIf this option is used, each file passed to your router request will have a `transforms` array, with every transform you defined.\n```json\n{\n  \"data\": {\n    \"fieldname\": \"image\",\n    \"originalname\": \"image.jpg\",\n    \"encoding\": \"7bit\",\n    \"mimetype\": \"image/jpg\",\n    \"transforms\": [\n      {\n        \"id\": \"thumbnail\",\n        \"size\": 2440,\n        \"bucket\": \"some-bucket\",\n        \"key\": \"image-thumbnail.jpg\",\n        \"acl\": \"public-read\",\n        \"contentType\": \"image/jpg\",\n        \"metadata\": null,\n        \"location\": \"https://some-bucket.s3.us-east-1.amazonaws.com/image-thumbnail.jpg\",\n        \"etag\": \"\\\"9d554e03e37c79bff7ce31d375900db6\\\"\"\n      },\n      {\n        \"id\": \"original\",\n        \"size\": 18006,\n        \"bucket\": \"some-bucket\",\n        \"key\": \"image-original.jpg\",\n        \"acl\": \"public-read\",\n        \"contentType\": \"image/jpg\",\n        \"metadata\": null,\n        \"location\": \"https://some-bucket.s3.us-east-1.amazonaws.com/image-original.jpg\",\n        \"etag\": \"\\\"76c09df7bdd752a749f91b9663838fb2\\\"\"\n      },\n    ]\n  }\n}\n```\n## Testing\n\nThe tests mock all access to S3 and can be run completely offline.\n\n```sh\nnpm test\n```\n","maintainers":[{"name":"kaiyuhsu","email":"im.kaiyu@gmail.com"}],"time":{"modified":"2022-06-20T13:14:22.768Z","created":"2017-03-21T22:46:07.186Z","2.3.2":"2017-03-21T22:46:07.186Z","2.10.0":"2020-11-17T07:40:58.366Z","2.10.1":"2020-11-17T07:46:01.275Z","2.10.2":"2020-11-17T07:49:41.557Z","2.10.3":"2020-11-17T13:08:08.875Z"},"homepage":"https://github.com/tehkaiyu/multer-s3#readme","keywords":["multer","s3","amazon","aws"],"repository":{"type":"git","url":"git+https://github.com/tehkaiyu/multer-s3.git"},"author":{"name":"badunk"},"bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"license":"MIT","readmeFilename":"README.md"}