{"id":19776815,"url":"https://github.com/chenglongma/skipper-gcstorage","last_synced_at":"2025-04-30T19:31:05.312Z","repository":{"id":38963941,"uuid":"303901132","full_name":"ChenglongMa/skipper-gcstorage","owner":"ChenglongMa","description":"A Skipper adapter for Google Cloud storage.","archived":false,"fork":false,"pushed_at":"2023-11-18T11:58:59.000Z","size":125,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T06:37:21.789Z","etag":null,"topics":["file-upload","google-cloud","google-cloud-storage","sails-hook","sailsjs","skipper","uploader"],"latest_commit_sha":null,"homepage":"https://chenglongma.com/skipper-gcstorage/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChenglongMa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-10-14T04:19:38.000Z","updated_at":"2024-02-05T23:45:39.000Z","dependencies_parsed_at":"2023-12-19T01:52:10.382Z","dependency_job_id":"2c52129b-bb8d-4947-b89a-8ec3c13562da","html_url":"https://github.com/ChenglongMa/skipper-gcstorage","commit_stats":{"total_commits":31,"total_committers":3,"mean_commits":"10.333333333333334","dds":0.3548387096774194,"last_synced_commit":"7f4149e895b60a78ece11c17f2990b650405b1f4"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenglongMa%2Fskipper-gcstorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenglongMa%2Fskipper-gcstorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenglongMa%2Fskipper-gcstorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenglongMa%2Fskipper-gcstorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChenglongMa","download_url":"https://codeload.github.com/ChenglongMa/skipper-gcstorage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251769283,"owners_count":21640877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-upload","google-cloud","google-cloud-storage","sails-hook","sailsjs","skipper","uploader"],"created_at":"2024-11-12T05:21:59.022Z","updated_at":"2025-04-30T19:31:04.944Z","avatar_url":"https://github.com/ChenglongMa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [\u003cimg title=\"skipper-gcstorage - Google Cloud Storage adapter for Skipper\" src=\"http://i.imgur.com/P6gptnI.png\" width=\"200px\" alt=\"skipper emblem - face of a ship's captain\"/\u003e](https://github.com/ChenglongMa/skipper-gcstorage.git) Google Cloud Storage Blob Adapter\n\n![npm](https://img.shields.io/npm/v/skipper-gcstorage)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/chenglongma/skipper-gcstorage)\n![NPM](https://img.shields.io/npm/l/skipper-gcstorage)\n\n**Google Cloud Storage** adapter for receiving [upstreams](https://github.com/balderdashy/skipper#what-are-upstreams).\nParticularly useful for handling streaming multipart file uploads from\nthe [Skipper](https://github.com/balderdashy/skipper) body parser.\n\n## Installation\n\n### Option 1: NPM Package\n\n[![NPM](https://nodei.co/npm/skipper-gcstorage.png)](https://npmjs.org/package/skipper-gcstorage)\n\n```bash\n$ npm i skipper-gcstorage\n```\n\n### ~~Option2: GitHub Package~~ [Deprecated: GitHub package won't update any more, the last version is v2.2.0]\n\n[![GitHub](https://nodei.co/npm/@chenglongma/skipper-gcstorage.png)](https://github.com/ChenglongMa/skipper-gcstorage/packages)\n\n```bash\n$ npm i @chenglongma/skipper-gcstorage\n```\n\n## Changelog\n\n### Ver 2.3.0\n\n1. Add `keepName` option which can set whether to use original filename or a generated UUID name.\n2. Update dependencies to the latest version.\n\n### Ver 2.2.0\n\n1. Update dependencies to the latest version.\n    1. [sharp](https://sharp.pixelplumbing.com/): 0.29.2, now it supports M1 chipset (\n       thanks [lahiruelectrily (github.com)](https://github.com/lahiruelectrily))\n    2. [mime](https://www.npmjs.com/package/mime): 3.0.0\n\n### Ver 2.1.0\n\nThanks [jspark-gigworks (Anselmo Park)](https://github.com/jspark-gigworks) so much for his comments!\n\n1. Emit `writefile` event when finishing the job.\n2. Support additional `CreateWriteStreamOptions` listed\n   in https://googleapis.dev/nodejs/storage/latest/global.html#CreateWriteStreamOptions.\n\n### Ver 2.0.0\n\n1. Add `resize` options, which can compress the **images** before uploading.\n\n## Usage\n\n```javascript\nreq.file('avatar')\n    .upload({\n        // Required\n        adapter: require('skipper-gcstorage'),\n        bucket: 'existing_or_new_bucket_name', // Will create new one if no such bucket exists.\n        // Optional\n        projectId: 'GOOGLE_CLOUD_PROJECT', // Mandatory if `keyFilename` was specified.\n        keyFilename: '/path/to/GOOGLE_APPLICATION_CREDENTIALS.json',\n        bucketMetadata: {\n            location: 'us-west1',\n        },  // Refer to https://googleapis.dev/nodejs/storage/latest/global.html#CreateBucketRequest\n        maxBytes: 60000,\n        metadata: {},\n        public: true,\n        gzip: true,\n        keepName: false,\n        // Other options in `CreateWriteStreamOptions`\n        // Refer to https://googleapis.dev/nodejs/storage/latest/global.html#CreateWriteStreamOptions\n        ...CreateWriteStreamOptions,\n        resize: {\n            width: 500,\n            height: 500\n        }, // Refer to https://sharp.pixelplumbing.com/api-resize#resize\n    }, function whenDone(err, uploadedFiles) {\n        if (err) {\n            return res.serverError(err);\n        }\n        return res.ok({\n            files: uploadedFiles,\n            textParams: req.params.all()\n        });\n    });\n```\n\nPlease don't check in your GCP credentials :)\n\n### Parameters\n\n| Name                        | Type                                      | Required                          | Default Value                                                                  | Description                                                                                                                                                                                                               |\n|-----------------------------|-------------------------------------------|-----------------------------------|--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| bucket                      | string                                    | Yes                               | None                                                                           | Bucket name in GCP, will create new one if there is no such bucket.                                                                                                                                                       |\n| projectId                   | string                                    | Yes if `keyFilename` is specified | None, will try to read `process.env.GOOGLE_CLOUD_PROJECT` if not set           | \"GOOGLE_CLOUD_PROJECT\", please refer to [Google Cloud Storage#using-the-client-library](https://googleapis.dev/nodejs/storage/latest/index.html#using-the-client-library)                                                 |\n| keyFilename                 | string                                    | No                                | None, will try to read `process.env.GOOGLE_APPLICATION_CREDENTIALS` if not set | \"/path/to/GOOGLE_APPLICATION_CREDENTIALS.json\"                                                                                                                                                                            |\n| bucketMetadata              | dictionary                                | No                                | {}                                                                             | Metadata to set for the bucket. Refer to [Google Cloud Storage#CreateBucketRequest](https://googleapis.dev/nodejs/storage/latest/global.html#CreateBucketRequest)                                                         |\n| metadata                    | dictionary                                | No                                | {}                                                                             | Extra info attached to the file                                                                                                                                                                                           |\n| public                      | boolean                                   | No                                | true                                                                           | Whether to make the file public                                                                                                                                                                                           |\n| keepName                    | boolean or string                         | No                                | false                                                                          | Whether to use original filename. The uploaded file will be set to: \u003cbr/\u003e* a **UUID name** if `keepName=false`; \u003cbr/\u003e* its **original name** if `keepName=true`; \u003cbr/\u003e* the value of `keepName` if `keepName` is a string |\n| ...CreateWriteStreamOptions | expanded dictionary                       | No                                | {}                                                                             | Options for `File#createWriteStream()`. Refer to [Google Cloud Storage#CreateWriteStreamOptions](https://googleapis.dev/nodejs/storage/latest/global.html#CreateWriteStreamOptions)                                       |\n| resize                      | dictionary with keys `width` and `height` | No                                | {}                                                                             | The new size of image. Only works when the file is an image. Refer to [sharp#resize](https://sharp.pixelplumbing.com/api-resize#resize).                                                                                  |\n\n\n\n### NOTE\n\n1. `Skipper-GCStorage` will create new bucket if specified one does not exist.\n    1. Assign bucket metadata into `bucketMetadata`.\n2. Support multiple ways for **Authentication**\n    1. Specify `projectId` AND `keyFilename`;\n    2. `export` `GOOGLE_APPLICATION_CREDENTIALS` environment variable;\n    3. Login with an eligible [service account](https://cloud.google.com/iam/docs/service-accounts);\n    4. \\*For more details, please refer to https://cloud.google.com/docs/authentication/production#command-line.\n3. Use with [sails-hook-uploads](https://www.npmjs.com/package/sails-hook-uploads) for better results :)\n4. \u003e Cloud Storage operates with a flat namespace, which means that folders don't actually exist within Cloud Storage.\n   \u003e If you create an object named `folder1/file.txt` in the bucket `your-bucket`, the path to the object is `your-bucket/folder1/file.txt`, \n   \u003e but there is no folder named `folder1`; instead, the string `folder1` is part of the object's name. \n     \n   Please refer to https://cloud.google.com/storage/docs/folders\n\n## Acknowledgement\n\n1. [Sails Skipper](https://github.com/sailshq/skipper)\n2. [Skipper-S3](https://github.com/balderdashy/skipper-s3)\n3. [jspark-gigworks (Anselmo Park)](https://github.com/jspark-gigworks)\n\n## Contribution\n\nPull requests are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenglongma%2Fskipper-gcstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenglongma%2Fskipper-gcstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenglongma%2Fskipper-gcstorage/lists"}