{"_id":"multer-s3-svgsanitycheck","_rev":"3-3acd5b0570af4240f007a40c6343d04b","name":"multer-s3-svgsanitycheck","dist-tags":{"latest":"3.0.5"},"versions":{"3.0.3":{"name":"multer-s3-svgsanitycheck","version":"3.0.3","keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","_id":"multer-s3-svgsanitycheck@3.0.3","maintainers":[{"name":"boehlerlukas","email":"lukas@gleap.io"}],"homepage":"https://github.com/GleapSDK/multer-s3#readme","bugs":{"url":"https://github.com/GleapSDK/multer-s3/issues"},"dist":{"shasum":"a76e4318a06f51a45f62054faac84080287cc1b8","tarball":"https://registry.npmjs.org/multer-s3-svgsanitycheck/-/multer-s3-svgsanitycheck-3.0.3.tgz","fileCount":12,"integrity":"sha512-63Azqjnql8JlGAULUStyAZcRTNtUHyHhOCMvuHXCgdFsL+WX1Tc+5QpCjtKFK+dSIqR4E9oXZwCuHNXT1HNtUA==","signatures":[{"sig":"MEUCIDyor7ko9/MUyz+/x3Iu1YAaJ7m+dEKuUPaM5CimkhWdAiEAlqMY/2GQzLcMH7mxfRiV7NNPMgCneHpzVtDcUhW4x9k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34428},"main":"index.js","engines":{"node":">= 12.0.0"},"gitHead":"6a3bfcb9b564ebcbd91696ddc5f5f6814fb1f587","scripts":{"test":"standard && mocha test/basic.js"},"_npmUser":{"name":"boehlerlukas","email":"lukas@gleap.io"},"repository":{"url":"git+https://github.com/GleapSDK/multer-s3.git","type":"git"},"_npmVersion":"10.7.0","description":"Streaming multer storage engine for AWS S3","directories":{},"_nodeVersion":"20.14.0","dependencies":{"file-type":"^3.3.0","run-parallel":"^1.1.6","sanitize-html":"^2.13.1","html-comment-regex":"^1.1.2","@aws-sdk/lib-storage":"^3.46.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^2.2.5","xtend":"^4.0.1","multer":"^1.1.0","express":"^4.13.1","standard":"^5.4.1","form-data":"^1.0.0-rc3","on-finished":"^2.3.0"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/multer-s3-svgsanitycheck_3.0.3_1730281409399_0.8771584672530772","host":"s3://npm-registry-packages"}},"3.0.4":{"name":"multer-s3-svgsanitycheck","version":"3.0.4","keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","_id":"multer-s3-svgsanitycheck@3.0.4","maintainers":[{"name":"boehlerlukas","email":"lukas@gleap.io"}],"homepage":"https://github.com/GleapSDK/multer-s3#readme","bugs":{"url":"https://github.com/GleapSDK/multer-s3/issues"},"dist":{"shasum":"537386f6fa72269af4c4c709fc7406cec92ed31d","tarball":"https://registry.npmjs.org/multer-s3-svgsanitycheck/-/multer-s3-svgsanitycheck-3.0.4.tgz","fileCount":12,"integrity":"sha512-X2XwjM55zuPIT7tYuiVaKxwcfVRXVJbvAoxN78nGZgEE8Tt6+cVw3mrjoyS1vajZmUq4GNlDfYFTYb+O2zi96Q==","signatures":[{"sig":"MEQCIBZTb60LFNafqNR40qo8ou5iX54naVNjxHSk2KLkeR3hAiAcJ8xF8fSjI3wgluFDjHO6mN8DXbFUhql8swYFLnB3TQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34501},"main":"index.js","engines":{"node":">= 12.0.0"},"gitHead":"6a3bfcb9b564ebcbd91696ddc5f5f6814fb1f587","scripts":{"test":"standard && mocha test/basic.js"},"_npmUser":{"name":"boehlerlukas","email":"lukas@gleap.io"},"repository":{"url":"git+https://github.com/GleapSDK/multer-s3.git","type":"git"},"_npmVersion":"10.7.0","description":"Streaming multer storage engine for AWS S3","directories":{},"_nodeVersion":"20.14.0","dependencies":{"file-type":"^3.3.0","run-parallel":"^1.1.6","sanitize-html":"^2.13.1","html-comment-regex":"^1.1.2","@aws-sdk/lib-storage":"^3.46.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^2.2.5","xtend":"^4.0.1","multer":"^1.1.0","express":"^4.13.1","standard":"^5.4.1","form-data":"^1.0.0-rc3","on-finished":"^2.3.0"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/multer-s3-svgsanitycheck_3.0.4_1730282163365_0.042950606698196836","host":"s3://npm-registry-packages"}},"3.0.5":{"name":"multer-s3-svgsanitycheck","version":"3.0.5","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"engines":{"node":">= 12.0.0"},"repository":{"type":"git","url":"git+https://github.com/GleapSDK/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":{"name":"badunk"},"license":"MIT","bugs":{"url":"https://github.com/GleapSDK/multer-s3/issues"},"homepage":"https://github.com/GleapSDK/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.46.0","file-type":"^3.3.0","html-comment-regex":"^1.1.2","run-parallel":"^1.1.6","sanitize-html":"^2.13.1"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"devDependencies":{"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":"b7365a098d0c6b68fbab7366084a74af625f390d","_id":"multer-s3-svgsanitycheck@3.0.5","_nodeVersion":"25.8.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-Ak3R/Lfs2Xqp5+ypPHrFbC9cmwPBttNK5sD8SC0ykILPrsZXlP+0lAF9/AtwBCdPiDQSFwGq9rztm3O6b4dxTw==","shasum":"f9dc15e7ad67bd9c958d3248e539a248dcc1adda","tarball":"https://registry.npmjs.org/multer-s3-svgsanitycheck/-/multer-s3-svgsanitycheck-3.0.5.tgz","fileCount":12,"unpackedSize":35473,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCl9Aoyos8HUGhGGtFP2fhykj/HwdOiNeBOu+G7AtTdoQIhALkoqF9txIiHn0i7grpRDCX6xQQA73Zxh3cUaLl449yy"}]},"_npmUser":{"name":"boehlerlukas","email":"lukas@gleap.io"},"directories":{},"maintainers":[{"name":"boehlerlukas","email":"lukas@gleap.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/multer-s3-svgsanitycheck_3.0.5_1779284349897_0.33233153182595254"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-30T09:43:29.398Z","modified":"2026-05-20T13:39:10.175Z","3.0.3":"2024-10-30T09:43:29.560Z","3.0.4":"2024-10-30T09:56:03.530Z","3.0.5":"2026-05-20T13:39:10.051Z"},"bugs":{"url":"https://github.com/GleapSDK/multer-s3/issues"},"author":{"name":"badunk"},"license":"MIT","homepage":"https://github.com/GleapSDK/multer-s3#readme","keywords":["multer","s3","amazon","aws"],"repository":{"type":"git","url":"git+https://github.com/GleapSDK/multer-s3.git"},"description":"Streaming multer storage engine for AWS S3","maintainers":[{"name":"boehlerlukas","email":"lukas@gleap.io"}],"readme":"# Multer S3\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 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"}