{"_id":"@beezsocialerp/multer-cloud-storage","_rev":"1-6e1ed15d352c8afcf009c229024a5c64","name":"@beezsocialerp/multer-cloud-storage","dist-tags":{"latest":"2.8.1"},"versions":{"2.8.1":{"name":"@beezsocialerp/multer-cloud-storage","version":"2.8.1","description":"Multer storage engine for Google Cloud Storage","main":"lib/index.js","typings":"lib/index","engines":{"node":">=10"},"scripts":{"test":"npm run build && jest","build":"tsc","clean":"rimraf lib"},"keywords":["multer","node","gcs","google","cloud","storage"],"author":{"name":"Alexandre Steinberg"},"license":"MIT","dependencies":{"@google-cloud/storage":"^5.8.5","@types/express":"^4.17.12","multer":"^1.4.2","urlencode":"^1.1.0","uuid":"^8.3.2"},"devDependencies":{"@types/jest":"^26.0.23","@types/multer":"^1.4.5","@types/node":"^15.12.2","@types/urlencode":"^1.1.2","jest":"^27.0.4","rimraf":"^3.0.2","typescript":"^4.3.2"},"repository":{"type":"git","url":"git+https://github.com/alexandre-steinberg/multer-cloud-storage.git"},"gitHead":"417f850cdf0de72a0d30fa59524238873138d130","bugs":{"url":"https://github.com/alexandre-steinberg/multer-cloud-storage/issues"},"homepage":"https://github.com/alexandre-steinberg/multer-cloud-storage#readme","_id":"@beezsocialerp/multer-cloud-storage@2.8.1","_nodeVersion":"14.15.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-adNLgw0GAA90qSV/333oltBacOgx7p3393d4hyFeVvmVaMEM+r8cDIfwEJJ4RC736sGEn6FI7sbZaFQH3I5WjA==","shasum":"e05cb013d238c889d504fb9fe2f97e855144d094","tarball":"https://registry.npmjs.org/@beezsocialerp/multer-cloud-storage/-/multer-cloud-storage-2.8.1.tgz","fileCount":14,"unpackedSize":39423,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4sqZCRA9TVsSAnZWagAAEkwQAJfN+zaDwbOiSFW5BJle\n+uErwp2LLy+o5/Et3QekUEc1PySBDsZoMf5WyXBUa8sTA2xIFJOmk8lWUBw5\nHuEa6HHZsoZ6hxHiyU0KRnp9nqI25NDnaZwp+C8nwoRiPJhH5CZ1H1GRL9i/\npx/CaogWI/9RrqbG5tTbmYItK9W2ZwoK39I6x820nX6Wa+eYA1nJgLYUVXVs\nfcWNG7sQW2Es1tPyylkVh05F1wIGRSmDhBH9/iJf7fcYeZIfNtuStsn83ltD\nhS4rFQpIwacc3KtbH2citgPGQ50RRku+m4gr1Wv7SiPl/VbGSf33/JVjPx0z\npqaMH39WYojbGPmk9+ayXSq8yJqT7aSZCg17DEz92v9+BBsRGYvk8lwqX/we\n1vVjOr/hNOHOoFLuZIBvA9cZQVK/Nk8Sws2Kd/WnjXne4Q1zLJPusxPIW1VP\nluy+//ZVBlkwji2YqiGeH6G3/GfkpwSLyBCbGCmgYT5d/MxtatIl5CvgEo1c\nCr7/iLlEGHb/Wy8Nlq6wFgPQ5xxbiTGWRIsFdg57gjmNSk3YQ6P5gYv07X4e\nGnmeDuSUHDRuSydOarUFQJzZInRorXnPxv09nlGbULX3lnOpR6ZKkB1izzTT\nsTEL2YflLB8OGjdsHSdUDmG5jT+3yR35arSUVR4Qf/z8N1HJH02NWN59PcsT\ndy5h\r\n=FhWr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCX90tZQ0Xwzq/1ahi/tVAv2soCTaGvj6Uc24X5SBtFfAIgUjTEwQ4mDPzq/h5O+ceu8QtwiksPGzncpfr1oWJJMnE="}]},"_npmUser":{"name":"beezdev","email":"dev@beezsocialerp.com"},"directories":{},"maintainers":[{"name":"beezdev","email":"dev@beezsocialerp.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-cloud-storage_2.8.1_1625475737413_0.7207226560239473"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-05T09:02:17.023Z","2.8.1":"2021-07-05T09:02:17.581Z","modified":"2022-04-04T18:11:12.829Z"},"maintainers":[{"name":"beezdev","email":"dev@beezsocialerp.com"}],"description":"Multer storage engine for Google Cloud Storage","homepage":"https://github.com/alexandre-steinberg/multer-cloud-storage#readme","keywords":["multer","node","gcs","google","cloud","storage"],"repository":{"type":"git","url":"git+https://github.com/alexandre-steinberg/multer-cloud-storage.git"},"author":{"name":"Alexandre Steinberg"},"bugs":{"url":"https://github.com/alexandre-steinberg/multer-cloud-storage/issues"},"license":"MIT","readme":"# multer-cloud-storage\n[![last commit](https://badgen.net/github/last-commit/alexandre-steinberg/multer-cloud-storage)](https://github.com/alexandre-steinberg/multer-cloud-storage)\n[![npm version](https://badgen.net/npm/v/multer-cloud-storage)](https://www.npmjs.com/package/multer-cloud-storage)\n[![MIT License](https://badgen.net/npm/license/multer-cloud-storage)](https://opensource.org/licenses/MIT)\n[![node](https://badgen.net/npm/node/multer-cloud-storage)](https://nodejs.org/en/)\n[![packagephobia install size](https://badgen.net/packagephobia/install/multer-cloud-storage)](https://packagephobia.now.sh/result?p=multer-cloud-storage)\n[![packagephobia publish size](https://badgen.net/packagephobia/publish/multer-cloud-storage)](https://packagephobia.now.sh/result?p=multer-cloud-storage)\n\nmulter-cloud-storage is a [multer](https://github.com/expressjs/multer) custom store engine for Google Cloud Storage service. It is a fork from ARozar's [multer-google-storage](https://github.com/ARozar/multer-google-storage) that uses latest version of Google Cloud's API, allows additional information (like destination and contentType) to be set and reduces module footprint.\n\n## Installation\n\n    npm install multer-cloud-storage --save\n\nor\n\n    yarn add multer-cloud-storage\n\n\n## Usage\n### ES6\n\n    import * as multer from 'multer';\n    import * as express from 'express';\n    import MulterGoogleCloudStorage from 'multer-cloud-storage';\n\n    const app = express();\n\n    const uploadHandler = multer({\n      storage: new MulterGoogleCloudStorage()\n    });\n\n    app.post('/upload', uploadHandler.any(), (req, res) => {\n        console.log(req.files);\n        res.json(req.files);\n    });\n\n### ES5 / Common.js imports\n\n    var multer = require(\"multer\");\n    var express = require(\"express\");\n    var multerGoogleStorage = require(\"multer-cloud-storage\");\n    var app = express();\n    var uploadHandler = multer({\n        storage: multerGoogleStorage.storageEngine()\n    });\n    app.post('/upload', uploadHandler.any(), function (req, res) {\n        console.log(req.files);\n        res.json(req.files);\n    });\n\nNB: This package is written to work with es5 or higher. If you have an editor or IDE that can understand d.ts (typescript) type definitions you will get additional support from your tooling though you do not need to be using typescript to use this package.\n\n## Google Cloud\n### Creating a storage bucket\nFor instructions on how to create a storage bucket see the following [documentation from Google](https://cloud.google.com/storage/docs/creating-buckets#storage-create-bucket-console).\n\n### Obtaining credentials\nFor instructions on how to obtain the JSON keyfile as well a *projectId* (contained in the key file) please refer to the following [documentation from Google](https://cloud.google.com/docs/authentication/getting-started).\n\n### Credentials\n#### Default method\nIf using the MulterGoogleCloudStorage class without passing in any configuration options then the following environment variables will need to be set:\n1. GCS_BUCKET, the name of the bucket to save to.\n2. GCLOUD_PROJECT, this is your projectId.  It can be found in the json credentials that you generated.\n3. GCS_KEYFILE, this is the path to the json key that you generated.\n\n#### Explicit method\nThe constructor of the MulterGoogleCloudStorage class can be passed an optional configuration object.\n\nParameter Name | Type | Sample Value | Default Value | Notes\n--- | --- | --- | --- | ---\n`acl`|`string`|`\"publicRead\"`|`\"private\"`|Accepted values are defined in  [*predefinedAcl*](https://googleapis.dev/nodejs/storage/latest/global.html#CreateWriteStreamOptions) options\n`autoRetry`|`boolean`|`true`| `true`| \n`bucket`|`string`|`\"mybucketname\"`| |Takes precedence over GCS_BUCKET\n`contentType`|`function`|`(request, file): string`| | \n`contentType`|`string`|`\"application/pdf\"`| |If set, this value will be used in place of *file.mimetype*\n`destination`|`string`|`\"my_folder/\"`|`\"\"`|Despite Google Cloud Storage service stores objects in a flat name space, it is possible to list and filter them in a tree-like structure (more on [How Subdirectories Work article](https://cloud.google.com/storage/docs/gsutil/addlhelp/HowSubdirectoriesWork))\n`email`|`string`|`\"test@test.com\"`| | \n`filename`| `function`|`(request, file, callback): void`| | \n`filename`| `string`|`\"my_file.pdf\"`| |If defined, this name will be used in place of *file.originalname* - use with caution, because the object can be easily overwritten (consider to configure [Object Versioning and Concurrency Control](https://cloud.google.com/storage/docs/gsutil/addlhelp/ObjectVersioningandConcurrencyControl))\n`hideFilename`|`boolean`|`true`|`false`|If set to *true*, an UUID v4 will be used as object filename and *Content-Type* will be undefined\n`keyFilename`|`string`|`\"./key.json\"`| |Takes precedence over GCS_KEYFILE\n`maxRetries`|`number`|`5`|`3`| | \n`projectId`|`string`|`\"test-prj-1234\"`| |Takes precedence over GCLOUD_PROJECT\n`uniformBucketLevelAccess`|`boolean`|`true`| |Signifies whether `uniformBucketLevelAccess` is enabled on the target bucket. When `true`, the `predefinedAcl` parameter is removed from requests [as it causes `400 Bad Request` responses](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request). \n#### Custom file naming function\nIf you need to customize the naming of files then you are able to provide a function that will be called before uploading the file.  The third argument of the function must be a standard node callback so pass any error in the first argument (or null on sucess) and the string name of the file on success.\n\n\tgetFilename(req, file, cb) {\n    \tcb(null,`${file.originalname}`);\n\t}\n\n#### Custom content-type function\nIf you need to customize the content-type of files then you are able to provide a function that will be called before uploading the file. \n\n\tgetContentType( req, file ) {\n\t\treturn undefined;\n\t}\n\n## Changes in multer API\n\nWhen used with multer-cloud-storage, multer will present additional file information.\n\n### File information\n\nEach file contains the following information:\n\nKey | Description | Origin\n--- | --- | ---\n`fieldname` | Field name specified in the form | `multer`\n`originalname` | Name of the file on the user's computer | `multer`\n`encoding` | Encoding type of the file | `multer`\n`mimetype` | Mime type of the file | `multer`\n`bucket` | Bucket name | `multer-cloud-storage`\n`destination` | The pseudo-folder to which the file has been saved | `multer-cloud-storage`\n`filename` | The name of the file on Google Cloud Storage | `multer-cloud-storage`\n`path` | The full path to the uploaded file (basically `destination`+ `filename`) | `multer-cloud-storage`\n`contentType` | Content-type defined for stored object | `multer-cloud-storage`\n`size` | Size of the file in bytes | `multer-cloud-storage`\n`uri` | Google Cloud Storage path | `multer-cloud-storage`\n`linkUrl` | Download link for allowed users (may require authentication) | `multer-cloud-storage`\n`selfLink` | The link to the stored object (used for Cloud Storage APIs requests) | `multer-cloud-storage`","readmeFilename":"README.md"}