{"_id":"@balena/open-multer-s3","_rev":"13-df6682ba9064ca373bbccebc985616a8","name":"@balena/open-multer-s3","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0-build-3-2-0-274b2cc0fb79e231f7a6ba4eca405a3ffd810f68-1":{"name":"@balena/open-multer-s3","version":"0.1.0-build-3-2-0-274b2cc0fb79e231f7a6ba4eca405a3ffd810f68-1","keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","_id":"@balena/open-multer-s3@0.1.0-build-3-2-0-274b2cc0fb79e231f7a6ba4eca405a3ffd810f68-1","maintainers":[{"name":"dfunckt","email":"akiskesoglou@gmail.com"},{"name":"page","email":"page@balena.io"},{"name":"balena.io","email":"accounts+npm@balena.io"}],"homepage":"https://github.com/badunk/multer-s3#readme","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"dist":{"shasum":"8e8d3faf93a2361229bad2a2f2225265b2a3aa17","tarball":"https://registry.npmjs.org/@balena/open-multer-s3/-/open-multer-s3-0.1.0-build-3-2-0-274b2cc0fb79e231f7a6ba4eca405a3ffd810f68-1.tgz","fileCount":14,"integrity":"sha512-+sJ7r7BOuW7b2tA/6Hv1a5AZFoHSSPk2nCYKkMG7RvjBLH7AmELC1YoJ5YSEjDcbGvahMcZQR/qOPHWfe7djgQ==","signatures":[{"sig":"MEYCIQCaAdR8OLXwM8Ih7xFmsND6h66/od7vQ6xb15C7hTMfoAIhAMgctJAeqQCwUDQQyfuoUHdfYeYEIAtDngwrK+P4VasN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26159,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9Q2JACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo0oA/5AQlxjZ1wEQDUcIvrxME4oOi2dmyjXpp5YELqwlv/XFDvLf1G\r\nigjYmTQd6lnkfAjTTFFbYQ2zXeOeFPDg0Yih6/G3lxNcBtIYpZHuR/MrPoWb\r\nDUcl3SlRc/jT2qVfzQxKl4xzzknKN36qOVUhUKCXAOAgvOj98usDPoqYBc/+\r\nWLnnbQA/O4HDtelAB5j5onu1Tdh0kRNGYznmlx2rSXl9eY0v5LsH0gdsvLLd\r\nFiveeyYKrfnxDDm/n4XVgOKqrs3yCftNO1cBZu51EUrTe0fQgu1sbmtWC5ad\r\n73xPiRTawK1qn4zknW6mH5bIb4ApMJf1Xwsm7BCUlBgf5NRlk1X6XItyxIDM\r\nY/SwSqLJI2Fe4Bd6MTvO0FtVJktN6ZTIEJzBsiY8ul8uuUrbpBrGzOL1MJvR\r\n1CkjAWagI+J7HCCxegC2A5TUo862Aa3WrwnBffQggv7uOFvdiV1uIG+2xuf4\r\nLKNJtAWG8/8X9VNVEkxcn9PRVIPDt4bg/QLS8yCw5eOLsET8gaBmxAdM2Ro9\r\nkh+f0cqI8x9siZYbthXgOYwaoYmxS+qOPDkUcgnRQor5KnG8WzV1x6gEmLZb\r\n3U4KrN2p/JZ8kyIHkElXPCjcyjTXIfeyl/5o5c0WHJ/FcZx+wXpLu8z1XHNf\r\n6xJQx9azgUt9Tsze3KaMUKVaqiaaL+sMNF0=\r\n=opH8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","_from":"file:/home/runner/work/_temp/balena-open-multer-s3-0.1.0.tgz","types":"./index.d.ts","engines":{"node":">= 12.20"},"scripts":{"test":"standard && mocha test/__basic.js"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"_resolved":"/home/runner/work/_temp/balena-open-multer-s3-0.1.0.tgz","_integrity":"sha512-+sJ7r7BOuW7b2tA/6Hv1a5AZFoHSSPk2nCYKkMG7RvjBLH7AmELC1YoJ5YSEjDcbGvahMcZQR/qOPHWfe7djgQ==","repository":{"url":"git+https://github.com/balena-io-modules/multer-s3.git","type":"git"},"versionist":{"publishedAt":"2023-02-21T18:28:03.530Z"},"_npmVersion":"9.3.1","description":"Streaming multer storage engine for AWS S3 - Fork of multer-s3","directories":{},"_nodeVersion":"18.14.1","dependencies":{"file-type":"^16.5.3","run-parallel":"^1.1.6","html-comment-regex":"^1.1.2","@aws-sdk/url-parser":"3.200.0","@aws-sdk/lib-storage":"3.200.0","@aws-sdk/signature-v4-crt":"3.200.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","xtend":"^4.0.1","multer":"1.4.5-lts.1","express":"^4.13.1","standard":"^5.4.1","form-data":"^1.0.0-rc3","on-finished":"^2.3.0","aws-sdk-client-mock":"^2.0.1"},"peerDependencies":{"@aws-sdk/client-s3":"3.200.0"},"_npmOperationalInternal":{"tmp":"tmp/open-multer-s3_0.1.0-build-3-2-0-274b2cc0fb79e231f7a6ba4eca405a3ffd810f68-1_1677004169025_0.28147395926850916","host":"s3://npm-registry-packages"},"deprecated":"Deprecated: no longer maintained. The GitHub repository has been archived and no further releases will be published."},"0.1.0":{"name":"@balena/open-multer-s3","version":"0.1.0","keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","_id":"@balena/open-multer-s3@0.1.0","maintainers":[{"name":"dfunckt","email":"akiskesoglou@gmail.com"},{"name":"page","email":"page@balena.io"},{"name":"balena.io","email":"accounts+npm@balena.io"}],"homepage":"https://github.com/badunk/multer-s3#readme","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"dist":{"shasum":"c33b7b0f4c32373cde3a856ab3c58f7d7646be3b","tarball":"https://registry.npmjs.org/@balena/open-multer-s3/-/open-multer-s3-0.1.0.tgz","fileCount":10,"integrity":"sha512-T1Fd7HOgTOX77cX6peUM3G0F9EzHkc6BnnygiAlSOsTpdPirTTwD8svvB4UAdCTqajnYbPIz7erevbbi7BQaew==","signatures":[{"sig":"MEQCIBYHshljkuswcEFt4/Xky1IJfb3LPokkvmEORNX+vxeRAiBZPjC/pE9sFfiaCFTNWUzcclUbpUboS/KaaQbX0utRrw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26104,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9RA+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpXLA//bqxZPum+4nvwpOHiiSoyvX1lMgUAS1TYnmTazDu5pWNEmfa6\r\nqEwyMv83zG6v8Ts763YJTpN0AgxCpUbuboczXwI3gRICct3F8e2n+4ep/deS\r\n0J0kfwpBhRdIRUGKJWxAYUZRxOhoFVnb5V0rKfn2fme5bpr8MX3LhqwtxqgR\r\ncBTJZ/2+KT5fbuBgJDPiPTLTyjWoVr3ssmnDjmpd3+/N7LUxNAu0lP/we4Bh\r\noHL01LJITwBVB68QQT0UJQxKogtpCC+wZlpR2qGg/gwRRnhmiJffYP+bKA6h\r\ni5G70smXhXJeh53rzTPt8Fzq896Mw8O3Rgl9wohGqbbIi0CZ1PN+5poX7Bt9\r\n5a5/Te9K9CzkU/1JnADRcAI+8XGR7pQ1EYLSaIvzY+2opNtFtN61BM+mt10M\r\nOGXcpTOqaKnlusO4qmnFl3SBkG0tWOuHlOY9icVXzjtYWJLfRMoqI3vhqgKi\r\nF6P5GmL4IwW3CA0Tggj6F8RShZ/0/GUzbbvWw6VJMq6x2P4T28l5TjR7cy1R\r\nMGMqVhHAIpSf/JpEIpGx5ZuBBEOWh/RMXiHUD+pFdv4SYPAOF9qeWJwEAaSZ\r\nU0vxCeaK25WevLpuiZOO5zR2DA6dAIc55UhSxfQIx408QracCaBL4MRyF6JK\r\nNx388DF6nYpThuJrehnJsCT5iId7Yw4C5IQ=\r\n=0wa5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","_from":"file:/home/runner/work/_temp/balena-open-multer-s3-0.1.0.tgz","types":"./index.d.ts","engines":{"node":">= 12.20"},"scripts":{"test":"standard && mocha test/__basic.js"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"_resolved":"/home/runner/work/_temp/balena-open-multer-s3-0.1.0.tgz","_integrity":"sha512-T1Fd7HOgTOX77cX6peUM3G0F9EzHkc6BnnygiAlSOsTpdPirTTwD8svvB4UAdCTqajnYbPIz7erevbbi7BQaew==","repository":{"url":"git+https://github.com/balena-io-modules/multer-s3.git","type":"git"},"versionist":{"publishedAt":"2023-02-21T18:28:03.530Z"},"_npmVersion":"9.3.1","description":"Streaming multer storage engine for AWS S3 - Fork of multer-s3","directories":{},"_nodeVersion":"18.14.0","dependencies":{"file-type":"^16.5.3","run-parallel":"^1.1.6","html-comment-regex":"^1.1.2","@aws-sdk/url-parser":"3.200.0","@aws-sdk/lib-storage":"3.200.0","@aws-sdk/signature-v4-crt":"3.200.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","xtend":"^4.0.1","multer":"1.4.5-lts.1","express":"^4.13.1","standard":"^5.4.1","form-data":"^1.0.0-rc3","on-finished":"^2.3.0","aws-sdk-client-mock":"^2.0.1"},"peerDependencies":{"@aws-sdk/client-s3":"3.200.0"},"_npmOperationalInternal":{"tmp":"tmp/open-multer-s3_0.1.0_1677004862285_0.21387752597186926","host":"s3://npm-registry-packages"},"deprecated":"Deprecated: no longer maintained. The GitHub repository has been archived and no further releases will be published."}},"time":{"created":"2023-02-21T18:29:28.913Z","modified":"2026-01-29T08:31:44.853Z","0.1.0-build-3-2-0-274b2cc0fb79e231f7a6ba4eca405a3ffd810f68-1":"2023-02-21T18:29:29.163Z","0.1.0":"2023-02-21T18:41:02.508Z"},"bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"author":{"name":"badunk"},"license":"MIT","homepage":"https://github.com/badunk/multer-s3#readme","keywords":["multer","s3","amazon","aws"],"repository":{"url":"git+https://github.com/balena-io-modules/multer-s3.git","type":"git"},"description":"Streaming multer storage engine for AWS S3 - Fork of multer-s3","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"},{"name":"page","email":"page@balena.io"}],"readme":"# Open Multer S3\n\n## Credits\n\nFork of multer-s3\n\n\n## Intro\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 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## AWS SDK Versions\n\n3.x.x releases of multer-s3 use AWS JavaScript SDK v3. Specifically, it uses the Upload class from [@aws-sdk/lib-storage](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_lib_storage.html) which in turn calls the modular [S3Client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/classes/s3client.html).\n\n2.x.x releases for multer-s3 use AWS JavaScript SDK v2 via a call to [s3.upload](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property).\n\n## Installation\n\n```sh\nnpm install --save 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('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"}