{"_id":"@danhab99/multer-minio-storage-engine","_rev":"1-50017c649ed6f5b73bb37b943c81ad45","name":"@danhab99/multer-minio-storage-engine","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@danhab99/multer-minio-storage-engine","version":"1.0.0","description":"Streaming multer storage engine for Minio","main":"index.js","scripts":{"test":"mocha test/basic.js"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","minio","amazon","aws"],"author":{"name":"Saeed Sheikhi"},"license":"MIT","bugs":{"url":"https://github.com/saeedsheikhi/multer-minio-storage-engine/issues"},"homepage":"https://github.com/saeedsheikhi/multer-minio-storage-engine#readme","dependencies":{"file-type":"^3.3.0","is-svg":"^2.1.0","run-parallel":"^1.1.6"},"devDependencies":{"minio":"^7.0.15","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"},"directories":{"test":"test"},"publishConfig":{"access":"public"},"gitHead":"b70719356308d5a2c2058d3a7413eb1bea85286b","_id":"@danhab99/multer-minio-storage-engine@1.0.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-sdhurNN7dqcvMeZOtA0OUa4K1sdWYXqLrxmiZJhexwS6Z3xOYC0sgn9rzGhxx6ElR3kweMV2TGYoTRQ2mPzUMQ==","shasum":"e888f84ee738429febd97171b3f44524692fed9e","tarball":"https://registry.npmjs.org/@danhab99/multer-minio-storage-engine/-/multer-minio-storage-engine-1.0.0.tgz","fileCount":9,"unpackedSize":19089,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfW53+CRA9TVsSAnZWagAAyRsP/jgOoQCKNcUH54D28Sf/\nxnlunNVrLx8jttw/2yfBKp+ACy5c324rXWWXXB5AsYI62r3R4kECmlgpCQFp\nE+rG8KxvsvSC5crWY2fj7oedKVhtyXvuhZDjVXXjALPpQlQ0l4fFZ/v9C5Iu\nJND0axLbTeerSacWx3P6njtMwtd+4XaxV2Uq/gaGGgJ33kqUsgRzYfJFs9J8\n2anZMfw+KGWoFPGed8DofrZvrU3U3MWSJXdoU14fEdBMLbf0VNMeur4n4DH9\n8T1h4n2RXNm6Ukk2AePjXFMJOXupCrE0o5XPCnJBCje6S9oC3FtEOouhnZaR\npYQsf6prOT62pmQSy6f8G/Mi4nDQ8DE6GVxUEMvw7IOX1iCJwLlT7EX6iZ++\nz24vtSZ0GgUyBtM4P14QxIN5i9Z5Dyy7OVl2LFtoWHvJ8TKHqZ7rwQ60RYAy\nujETTKOAeVhPOUROR7wMRnOtavqcoCaRNHiNcGRXEi/CY0Pr68v8eJ4SfBTW\n+Q1QQjnxXoOcCvkf3zcSnnRFg1jCauhNs8fI/Xul07FFM6ADKAlCfrZSTLQg\nWhZU65ghhlTqBznXa9DHq2FHHhyAq2xcHrPWPWCWmSqik5UkqkJf/8gLsvoH\n6fGQ+1wfwGFAlo+/M85W/wZNRWwVvTu7kC9+/+xF27AHTmPhp4zyZKWynMdl\nlG1i\r\n=KcVf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHh7ljWXflJ113ogTJf2cvofQ5Aav1C5qKt1IuNyAMfHAiEA7+wQ10bLDStOTowMIPvZBoTKvLWwLsB/NZXuZANOE6w="}]},"maintainers":[{"name":"danhab99","email":"dan.habot@gmail.com"}],"_npmUser":{"name":"danhab99","email":"dan.habot@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-minio-storage-engine_1.0.0_1599839742092_0.37772581267722516"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-11T15:55:42.053Z","1.0.0":"2020-09-11T15:55:42.194Z","modified":"2022-04-05T02:40:20.984Z"},"maintainers":[{"name":"danhab99","email":"dan.habot@gmail.com"}],"description":"Streaming multer storage engine for Minio","homepage":"https://github.com/saeedsheikhi/multer-minio-storage-engine#readme","keywords":["multer","minio","amazon","aws"],"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"author":{"name":"Saeed Sheikhi"},"bugs":{"url":"https://github.com/saeedsheikhi/multer-minio-storage-engine/issues"},"license":"MIT","readme":"# Multer Minio Storage Engine\n\nStreaming multer storage engine for minio.\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 [MinIO Client SDK for Javascript](https://github.com/minio/minio-js) 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\nyarn add multer-minio-storage-engine\n```\n\n## Usage\n\n```javascript\nconst Minio = require('minio');\nconst express = require('express');\nconst multer = require('multer');\nconst multerMinio = require('multer-minio-storage-engine');\n\nconst app = express();\n\nconst minioClient = new Minio.Client({\n  /* ... */\n});\n\nconst upload = multer({\n  storage: multerMinio({\n    minio: minioClient,\n    bucketName: 'some-bucket',\n    metaData: function (req, file, cb) {\n      cb(null, {mimetype: file.mimetype});\n    },\n    objectName: function (req, file, cb) {\n      cb(null, Date.now().toString());\n    },\n    preprocess: {\n      '.suffix1': stream => stream,\n      '.suffix2': stream => stream,\n      '.suffix3': stream => stream,\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-minio-storage-engine`:\n\n| Key           | Description                            | Note        |\n| ------------- | -------------------------------------- | ----------- |\n| `size`        | Size of the file in bytes              |\n| `bucketName`  | The bucket used to store the file      | `S3Storage` |\n| `objectName`  | The name of the object                 | `S3Storage` |\n| `contentType` | The `mimetype` used to upload the file | `S3Storage` |\n| `metaData`    | The `metaData` object to be sent to S3 | `S3Storage` |\n| `etag`        | The `etag`of the uploaded file in S3   | `S3Storage` |\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 objectName:\n\n```javascript\nconst opts = {\n  minio: minioClient,\n  bucketName: 'some-bucket',\n  metaData: function (req, file, cb) {\n    cb(null, Object.assign({}, req.body));\n  },\n  objectName: function (req, file, cb) {\n    cb(null, req.params.id + '.jpg');\n  },\n};\n```\n\n## Preprocessing streams before upload\n\nThe `preprocess` option is an object that includes key-value pairs for transforming the input stream into multiple individual file objects. The key is a suffix that will be appended to the object's `objectName` and the value is a function that takes the input stream and should return a stream.\n\nFor example, you can use this feature in conjunction with [gm](https://www.npmjs.com/package/gm) to produce multiple different sizes of the uploaded image:\n\n```javascript\nconst gm = require('gm').subClass({imageMagick: true})\nconst opts = {\n  minio: minioClient,\n  bucketName: 'some-bucket',\n  metaData: function (req, file, cb) {\n    cb(null, Object.assign({}, req.body));\n  },\n  objectName: function (req, file, cb) {\n    cb(null, req.params.id + '.jpg');\n  },\n  preprocess: {\n    \"(100x100)\": stream => gm(stream).resize(100, 100).stream(), // Creates an object with (100x100) at the end\n    \"(200x200)\": stream => gm(stream).resize(200, 200).stream(), // for example if the object name is \"upload.jpg)\n    \"(300x300)\": stream => gm(stream).resize(300, 300).stream(), // we will have \"upload.jpg(100x100)\"\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-minio-storage-engine to automatically find the content-type of the file, use the `multerMinio.AUTO_CONTENT_TYPE` constant. Here is an example that will detect the content type of the file being uploaded.\n\n```javascript\nconst upload = multer({\n  storage: multerMinio({\n    minio: minioClient,\n    bucketName: 'some-bucket',\n    contentType: multerMinio.AUTO_CONTENT_TYPE,\n    objectName: function (req, file, cb) {\n      cb(null, Date.now().toString());\n    },\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<!--\n## Testing\n\nThe tests mock all access to Minio and can be run completely offline.\n\n```sh\nnpm test\n``` -->\n","readmeFilename":"README.md"}