mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
264
node_modules/gcs-resumable-upload/CHANGELOG.md
generated
vendored
Normal file
264
node_modules/gcs-resumable-upload/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,264 @@
|
||||
# Changelog
|
||||
|
||||
[npm history][1]
|
||||
|
||||
[1]: https://www.npmjs.com/package/gcs-resumable-upload?activeTab=versions
|
||||
|
||||
### [2.3.2](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.3.1...v2.3.2) (2019-12-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** TypeScript 3.7.0 causes breaking change in typings ([#285](https://www.github.com/googleapis/gcs-resumable-upload/issues/285)) ([3e671b2](https://www.github.com/googleapis/gcs-resumable-upload/commit/3e671b262a7ef5383fbc5e5b6232d7bcd2c6641e))
|
||||
* **typescript:** add return type for base uri getter ([#286](https://www.github.com/googleapis/gcs-resumable-upload/issues/286)) ([7121624](https://www.github.com/googleapis/gcs-resumable-upload/commit/71216249ee781714b73826ee7902ed1847402102))
|
||||
|
||||
### [2.3.1](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.3.0...v2.3.1) (2019-11-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docs:** add jsdoc-region-tag plugin ([#282](https://www.github.com/googleapis/gcs-resumable-upload/issues/282)) ([4942669](https://www.github.com/googleapis/gcs-resumable-upload/commit/494266901b0cdcc9956dda721a4ca19d3b4ced53))
|
||||
|
||||
## [2.3.0](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.2.5...v2.3.0) (2019-10-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support all query parameters during URI creation ([#275](https://www.github.com/googleapis/gcs-resumable-upload/issues/275)) ([383a490](https://www.github.com/googleapis/gcs-resumable-upload/commit/383a490))
|
||||
|
||||
### [2.2.5](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.2.4...v2.2.5) (2019-09-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* typecast metadata.size from string to number ([#263](https://www.github.com/googleapis/gcs-resumable-upload/issues/263)) ([64ea7a1](https://www.github.com/googleapis/gcs-resumable-upload/commit/64ea7a1))
|
||||
|
||||
### [2.2.4](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.2.3...v2.2.4) (2019-08-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* let gaxios handle API errors ([#255](https://www.github.com/googleapis/gcs-resumable-upload/issues/255)) ([7a913ef](https://www.github.com/googleapis/gcs-resumable-upload/commit/7a913ef))
|
||||
|
||||
### [2.2.3](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.2.2...v2.2.3) (2019-07-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update dependency google-auth-library to v5 ([#250](https://www.github.com/googleapis/gcs-resumable-upload/issues/250)) ([8bc4798](https://www.github.com/googleapis/gcs-resumable-upload/commit/8bc4798))
|
||||
|
||||
### [2.2.2](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.2.1...v2.2.2) (2019-07-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update dependency pumpify to v2 ([#237](https://www.github.com/googleapis/gcs-resumable-upload/issues/237)) ([a2a2636](https://www.github.com/googleapis/gcs-resumable-upload/commit/a2a2636))
|
||||
|
||||
### [2.2.1](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.2.0...v2.2.1) (2019-07-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* handle a `0` generation ([#247](https://www.github.com/googleapis/gcs-resumable-upload/issues/247)) ([0b991d5](https://www.github.com/googleapis/gcs-resumable-upload/commit/0b991d5)), closes [#246](https://www.github.com/googleapis/gcs-resumable-upload/issues/246)
|
||||
|
||||
## [2.2.0](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.1.1...v2.2.0) (2019-07-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docs:** make anchors work in jsdoc ([#238](https://www.github.com/googleapis/gcs-resumable-upload/issues/238)) ([86e4433](https://www.github.com/googleapis/gcs-resumable-upload/commit/86e4433))
|
||||
* expose 'Retry limit exceeded' server error message ([#240](https://www.github.com/googleapis/gcs-resumable-upload/issues/240)) ([40a1306](https://www.github.com/googleapis/gcs-resumable-upload/commit/40a1306))
|
||||
* make cache key unique by including generation ([#243](https://www.github.com/googleapis/gcs-resumable-upload/issues/243)) ([85f80ab](https://www.github.com/googleapis/gcs-resumable-upload/commit/85f80ab))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow removing cache file ([#244](https://www.github.com/googleapis/gcs-resumable-upload/issues/244)) ([eb8976a](https://www.github.com/googleapis/gcs-resumable-upload/commit/eb8976a))
|
||||
|
||||
### [2.1.1](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.1.0...v2.1.1) (2019-06-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update dependency configstore to v5 ([#234](https://www.github.com/googleapis/gcs-resumable-upload/issues/234)) ([9b957c6](https://www.github.com/googleapis/gcs-resumable-upload/commit/9b957c6))
|
||||
|
||||
## [2.1.0](https://www.github.com/googleapis/gcs-resumable-upload/compare/v2.0.0...v2.1.0) (2019-06-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support apiEndpoint override ([#230](https://www.github.com/googleapis/gcs-resumable-upload/issues/230)) ([41325ac](https://www.github.com/googleapis/gcs-resumable-upload/commit/41325ac))
|
||||
|
||||
## [2.0.0](https://www.github.com/googleapis/gcs-resumable-upload/compare/v1.1.0...v2.0.0) (2019-05-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update dependency abort-controller to v3 ([0c4f6c0](https://www.github.com/googleapis/gcs-resumable-upload/commit/0c4f6c0))
|
||||
* **deps:** update dependency gaxios to v2 ([#210](https://www.github.com/googleapis/gcs-resumable-upload/issues/210)) ([d5a1a5c](https://www.github.com/googleapis/gcs-resumable-upload/commit/d5a1a5c))
|
||||
* **deps:** update dependency google-auth-library to v4 ([#219](https://www.github.com/googleapis/gcs-resumable-upload/issues/219)) ([1e60178](https://www.github.com/googleapis/gcs-resumable-upload/commit/1e60178))
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* upgrade engines field to >=8.10.0 ([#213](https://www.github.com/googleapis/gcs-resumable-upload/issues/213)) ([5a81a8b](https://www.github.com/googleapis/gcs-resumable-upload/commit/5a81a8b))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* upgrade engines field to >=8.10.0 (#213)
|
||||
|
||||
## v1.1.0
|
||||
|
||||
03-26-2019 07:13 PDT
|
||||
|
||||
### New Features
|
||||
- feat: support ConfigStore configPath option ([#194](https://github.com/googleapis/gcs-resumable-upload/pull/194))
|
||||
|
||||
### Internal / Testing Changes
|
||||
- chore: publish to npm using wombat ([#197](https://github.com/googleapis/gcs-resumable-upload/pull/197))
|
||||
- build: use per-repo npm publish token ([#195](https://github.com/googleapis/gcs-resumable-upload/pull/195))
|
||||
- build: Add docuploader credentials to node publish jobs ([#192](https://github.com/googleapis/gcs-resumable-upload/pull/192))
|
||||
- build: use node10 to run samples-test, system-test etc ([#190](https://github.com/googleapis/gcs-resumable-upload/pull/190))
|
||||
- build: update release configuration
|
||||
|
||||
## v1.0.0
|
||||
|
||||
02-28-2019 06:27 PST
|
||||
|
||||
**This release has breaking changes**. The underlying transport library was changed from [request](https://github.com/request/request) to [gaxios](https://github.com/JustinBeckwith/gaxios). Any `response` objects returned via the API will now return a [`GaxiosResponse`](https://github.com/JustinBeckwith/gaxios/blob/88a47e000625d8192689acac5c40c0b1e1d963a2/src/gaxios.ts#L197-L203) object.
|
||||
|
||||
|
||||
#### Old Code
|
||||
```js
|
||||
.on('response', function (resp, metadata) {
|
||||
console.log(resp.statusCode);
|
||||
})
|
||||
```
|
||||
|
||||
#### New Code
|
||||
```js
|
||||
.on('response', function (resp) {
|
||||
console.log(resp.status);
|
||||
});
|
||||
```
|
||||
|
||||
### Implementation Changes
|
||||
- fix: replace request with gaxios ([#174](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/174))
|
||||
|
||||
### Documentation
|
||||
- docs: update links in contrib guide ([#184](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/184))
|
||||
- docs: add lint/fix example to contributing guide ([#177](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/177))
|
||||
|
||||
### Internal / Testing Changes
|
||||
- chore(deps): update dependency mocha to v6 ([#185](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/185))
|
||||
- build: use linkinator for docs test ([#183](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/183))
|
||||
- build: create docs test npm scripts ([#182](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/182))
|
||||
- build: test using @grpc/grpc-js in CI ([#181](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/181))
|
||||
- chore: move CONTRIBUTING.md to root ([#179](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/179))
|
||||
- chore(deps): update dependency typescript to ~3.3.0 ([#176](https://github.com/GoogleCloudPlatform/gcs-resumable-upload/pull/176))
|
||||
|
||||
## v0.14.1
|
||||
|
||||
01-25-2019 10:39 PST
|
||||
|
||||
### Implementation Changes
|
||||
|
||||
- fix: return GaxiosError directly ([#171](https://github.com/googleapis/gcs-resumable-upload/pull/171))
|
||||
|
||||
### Documentation
|
||||
|
||||
- build: exclude googleapis in 404 check. ([#172](https://github.com/googleapis/gcs-resumable-upload/pull/172))
|
||||
- build: exclude googleapis.com checks in 404 checker ([#170](https://github.com/googleapis/gcs-resumable-upload/pull/170))
|
||||
|
||||
## v0.14.0
|
||||
|
||||
01-23-2019 17:57 PST
|
||||
|
||||
### New Features
|
||||
- feat: support async functions ([#164](https://github.com/googleapis/gcs-resumable-upload/pull/164))
|
||||
- fix: use the reject handler for promises ([#144](https://github.com/googleapis/gcs-resumable-upload/pull/144))
|
||||
- feat: add progress events ([#135](https://github.com/googleapis/gcs-resumable-upload/pull/135))
|
||||
|
||||
### Dependencies
|
||||
- fix(deps): update dependency google-auth-library to v3 ([#165](https://github.com/googleapis/gcs-resumable-upload/pull/165))
|
||||
- refactor: use teeny-request (part 1) ([#141](https://github.com/googleapis/gcs-resumable-upload/pull/141))
|
||||
- chore(deps): update dependency @types/configstore to v4 ([#145](https://github.com/googleapis/gcs-resumable-upload/pull/145))
|
||||
- chore(deps): update dependency typescript to ~3.2.0 ([#140](https://github.com/googleapis/gcs-resumable-upload/pull/140))
|
||||
- chore(deps): update dependency gts to ^0.9.0 ([#137](https://github.com/googleapis/gcs-resumable-upload/pull/137))
|
||||
- chore(deps): update dependency through2 to v3 ([#131](https://github.com/googleapis/gcs-resumable-upload/pull/131))
|
||||
- refactor: move from axios back to request ([#123](https://github.com/googleapis/gcs-resumable-upload/pull/123))
|
||||
- chore(deps): update dependency nock to v10 ([#113](https://github.com/googleapis/gcs-resumable-upload/pull/113))
|
||||
- chore: update the version of typescript ([#106](https://github.com/googleapis/gcs-resumable-upload/pull/106))
|
||||
|
||||
### Documentation
|
||||
- build: ignore googleapis.com in doc link checker ([#166](https://github.com/googleapis/gcs-resumable-upload/pull/166))
|
||||
- build: check broken links in generated docs ([#162](https://github.com/googleapis/gcs-resumable-upload/pull/162))
|
||||
|
||||
### Internal / Testing Changes
|
||||
- fix: fix the unit tests ([#161](https://github.com/googleapis/gcs-resumable-upload/pull/161))
|
||||
- chore(build): inject yoshi automation key ([#160](https://github.com/googleapis/gcs-resumable-upload/pull/160))
|
||||
- chore: update nyc and eslint configs ([#159](https://github.com/googleapis/gcs-resumable-upload/pull/159))
|
||||
- chore: fix publish.sh permission +x ([#156](https://github.com/googleapis/gcs-resumable-upload/pull/156))
|
||||
- fix(build): fix Kokoro release script ([#155](https://github.com/googleapis/gcs-resumable-upload/pull/155))
|
||||
- build: add Kokoro configs for autorelease ([#154](https://github.com/googleapis/gcs-resumable-upload/pull/154))
|
||||
- chore: always nyc report before calling codecov ([#153](https://github.com/googleapis/gcs-resumable-upload/pull/153))
|
||||
- chore: nyc ignore build/test by default ([#152](https://github.com/googleapis/gcs-resumable-upload/pull/152))
|
||||
- chore: update synth and common config ([#150](https://github.com/googleapis/gcs-resumable-upload/pull/150))
|
||||
- fix(build): fix system key decryption ([#142](https://github.com/googleapis/gcs-resumable-upload/pull/142))
|
||||
- chore: add synth.metadata
|
||||
- chore: update eslintignore config ([#136](https://github.com/googleapis/gcs-resumable-upload/pull/136))
|
||||
- chore: use latest npm on Windows ([#134](https://github.com/googleapis/gcs-resumable-upload/pull/134))
|
||||
- chore: update CircleCI config ([#129](https://github.com/googleapis/gcs-resumable-upload/pull/129))
|
||||
- chore: include build in eslintignore ([#126](https://github.com/googleapis/gcs-resumable-upload/pull/126))
|
||||
- chore: update issue templates ([#121](https://github.com/googleapis/gcs-resumable-upload/pull/121))
|
||||
- chore: remove old issue template ([#119](https://github.com/googleapis/gcs-resumable-upload/pull/119))
|
||||
- build: run tests on node11 ([#118](https://github.com/googleapis/gcs-resumable-upload/pull/118))
|
||||
- chores(build): run codecov on continuous builds ([#112](https://github.com/googleapis/gcs-resumable-upload/pull/112))
|
||||
- chores(build): do not collect sponge.xml from windows builds ([#114](https://github.com/googleapis/gcs-resumable-upload/pull/114))
|
||||
- chore: update new issue template ([#111](https://github.com/googleapis/gcs-resumable-upload/pull/111))
|
||||
- build: fix codecov uploading on Kokoro ([#108](https://github.com/googleapis/gcs-resumable-upload/pull/108))
|
||||
- Update kokoro config ([#105](https://github.com/googleapis/gcs-resumable-upload/pull/105))
|
||||
- Update CI config ([#103](https://github.com/googleapis/gcs-resumable-upload/pull/103))
|
||||
- Update kokoro config ([#101](https://github.com/googleapis/gcs-resumable-upload/pull/101))
|
||||
- test: remove appveyor config ([#100](https://github.com/googleapis/gcs-resumable-upload/pull/100))
|
||||
- Update kokoro config ([#99](https://github.com/googleapis/gcs-resumable-upload/pull/99))
|
||||
- Enable prefer-const in the eslint config ([#98](https://github.com/googleapis/gcs-resumable-upload/pull/98))
|
||||
- Enable no-var in eslint ([#97](https://github.com/googleapis/gcs-resumable-upload/pull/97))
|
||||
- Update to new repo location ([#96](https://github.com/googleapis/gcs-resumable-upload/pull/96))
|
||||
- Update CI config ([#95](https://github.com/googleapis/gcs-resumable-upload/pull/95))
|
||||
|
||||
## v0.13.0
|
||||
|
||||
### Dependencies
|
||||
- fix(deps): update dependency google-auth-library to v2 (#89)
|
||||
- chore(deps): update dependency nyc to v13 (#86)
|
||||
|
||||
### Docs
|
||||
- docs: update the README (#79)
|
||||
|
||||
### Internal / Testing Changes
|
||||
- Retry npm install in CI (#92)
|
||||
- Update CI config (#90)
|
||||
- Update CI config (#88)
|
||||
- Update the CI config (#85)
|
||||
- chore: update CircleCI config
|
||||
- chore: ignore package-lock.json (#83)
|
||||
- chore: update renovate config (#81)
|
||||
- chore: enable noImplicitThis (#82)
|
||||
- chore: enable CI and synth script (#77)
|
||||
|
||||
## v0.12.0
|
||||
|
||||
### Implemenation Changes
|
||||
BREAKING CHANGE:
|
||||
- chore: drop support for node.js 4 (#75)
|
||||
|
||||
### Dependencies
|
||||
- chore(deps): update dependency gts to ^0.8.0 (#71)
|
||||
- fix(deps): update dependency configstore to v4 (#72)
|
||||
- chore(deps): update dependency typescript to v3 (#74)
|
||||
|
||||
### Internal / Testing Changes
|
||||
- chore: make it OSPO compliant (#73)
|
||||
- fix: quarantine axios types (#70)
|
21
node_modules/gcs-resumable-upload/LICENSE
generated
vendored
Normal file
21
node_modules/gcs-resumable-upload/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Google LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
266
node_modules/gcs-resumable-upload/README.md
generated
vendored
Normal file
266
node_modules/gcs-resumable-upload/README.md
generated
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
# gcs-resumable-upload
|
||||
> Upload a file to Google Cloud Storage with built-in resumable behavior
|
||||
|
||||
```sh
|
||||
$ npm install gcs-resumable-upload
|
||||
```
|
||||
```js
|
||||
const {upload} = require('gcs-resumable-upload');
|
||||
const fs = require('fs');
|
||||
|
||||
fs.createReadStream('titanic.mov')
|
||||
.pipe(upload({ bucket: 'legally-owned-movies', file: 'titanic.mov' }))
|
||||
.on('finish', () => {
|
||||
// Uploaded!
|
||||
});
|
||||
```
|
||||
|
||||
Or from the command line:
|
||||
|
||||
```sh
|
||||
$ npm install -g gcs-resumable-upload
|
||||
$ cat titanic.mov | gcs-upload legally-owned-movies titanic.mov
|
||||
```
|
||||
|
||||
If somewhere during the operation, you lose your connection to the internet or your tough-guy brother slammed your laptop shut when he saw what you were uploading, the next time you try to upload to that file, it will resume automatically from where you left off.
|
||||
|
||||
## How it works
|
||||
|
||||
This module stores a file using [ConfigStore](http://gitnpm.com/configstore) that is written to when you first start an upload. It is aliased by the file name you are uploading to and holds the first 16kb chunk of data* as well as the unique resumable upload URI. ([Resumable uploads are complicated](https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#resumable))
|
||||
|
||||
If your upload was interrupted, next time you run the code, we ask the API how much data it has already, then simply dump all of the data coming through the pipe that it already has.
|
||||
|
||||
After the upload completes, the entry in the config file is removed. Done!
|
||||
|
||||
\* The first 16kb chunk is stored to validate if you are sending the same data when you resume the upload. If not, a new resumable upload is started with the new data.
|
||||
|
||||
## Authentication
|
||||
|
||||
Oh, right. This module uses [google-auth-library](http://gitnpm.com/google-auth-library) and accepts all of the configuration that module does to strike up a connection as `config.authConfig`. See [`authConfig`](https://github.com/google/google-auth-library-nodejs/#choosing-the-correct-credential-type-automatically).
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
const {gcsResumableUpload} = require('gcs-resumable-upload')
|
||||
const upload = gcsResumableUpload(config)
|
||||
```
|
||||
|
||||
`upload` is an instance of [`Duplexify`](http://gitnpm.com/duplexify).
|
||||
|
||||
---
|
||||
<a name="methods"></a>
|
||||
### Methods
|
||||
|
||||
#### upload.createURI(callback)
|
||||
|
||||
##### callback(err, resumableURI)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
Invoked if the authorization failed or the request to start a resumable session failed.
|
||||
|
||||
###### callback.resumableURI
|
||||
|
||||
- Type: `String`
|
||||
|
||||
The resumable upload session URI.
|
||||
|
||||
|
||||
#### upload.deleteConfig()
|
||||
|
||||
This will remove the config data associated with the provided file.
|
||||
|
||||
---
|
||||
<a name="config"></a>
|
||||
### Configuration
|
||||
|
||||
#### config
|
||||
|
||||
- Type: `object`
|
||||
|
||||
Configuration object.
|
||||
|
||||
##### config.authClient
|
||||
|
||||
- Type: [`GoogleAuth`](http://gitnpm.com/google-auth-library)
|
||||
- *Optional*
|
||||
|
||||
If you want to re-use an auth client from [google-auth-library](http://gitnpm.com/google-auth-library), pass an instance here.
|
||||
|
||||
##### config.authConfig
|
||||
|
||||
- Type: `object`
|
||||
- *Optional*
|
||||
|
||||
See [`authConfig`](https://github.com/google/google-auth-library-nodejs/#choosing-the-correct-credential-type-automatically).
|
||||
|
||||
##### config.bucket
|
||||
|
||||
- Type: `string`
|
||||
- **Required**
|
||||
|
||||
The name of the destination bucket.
|
||||
|
||||
##### config.configPath
|
||||
|
||||
- Type: `string`
|
||||
- *Optional*
|
||||
|
||||
Where the gcs-resumable-upload configuration file should be stored on your system. This maps to the [configstore option by the same name](https://github.com/yeoman/configstore/tree/0df1ec950d952b1f0dfb39ce22af8e505dffc71a#configpath).
|
||||
|
||||
##### config.file
|
||||
|
||||
- Type: `string`
|
||||
- **Required**
|
||||
|
||||
The name of the destination file.
|
||||
|
||||
##### config.generation
|
||||
|
||||
- Type: `number`
|
||||
- *Optional*
|
||||
|
||||
This will cause the upload to fail if the current generation of the remote object does not match the one provided here.
|
||||
|
||||
##### config.key
|
||||
|
||||
- Type: `string|buffer`
|
||||
- *Optional*
|
||||
|
||||
A [customer-supplied encryption key](https://cloud.google.com/storage/docs/encryption#customer-supplied).
|
||||
|
||||
##### config.kmsKeyName
|
||||
|
||||
- Type: `string`
|
||||
- *Optional*
|
||||
|
||||
Resource name of the Cloud KMS key, of the form `projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key`, that will be used to encrypt the object. Overrides the object metadata's `kms_key_name` value, if any.
|
||||
|
||||
##### config.metadata
|
||||
|
||||
- Type: `object`
|
||||
- *Optional*
|
||||
|
||||
Any metadata you wish to set on the object.
|
||||
|
||||
###### *config.metadata.contentLength*
|
||||
|
||||
Set the length of the file being uploaded.
|
||||
|
||||
###### *config.metadata.contentType*
|
||||
|
||||
Set the content type of the incoming data.
|
||||
|
||||
##### config.offset
|
||||
|
||||
- Type: `number`
|
||||
- *Optional*
|
||||
|
||||
The starting byte of the upload stream, for [resuming an interrupted upload](https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload#resume-upload).
|
||||
|
||||
##### config.origin
|
||||
|
||||
- Type: `string`
|
||||
- *Optional*
|
||||
|
||||
Set an Origin header when creating the resumable upload URI.
|
||||
|
||||
##### config.predefinedAcl
|
||||
|
||||
- Type: `string`
|
||||
- *Optional*
|
||||
|
||||
Apply a predefined set of access controls to the created file.
|
||||
|
||||
Acceptable values are:
|
||||
|
||||
- **`authenticatedRead`** - Object owner gets `OWNER` access, and `allAuthenticatedUsers` get `READER` access.
|
||||
- **`bucketOwnerFullControl`** - Object owner gets `OWNER` access, and project team owners get `OWNER` access.
|
||||
- **`bucketOwnerRead`** - Object owner gets `OWNER` access, and project team owners get `READER` access.
|
||||
- **`private`** - Object owner gets `OWNER` access.
|
||||
- **`projectPrivate`** - Object owner gets `OWNER` access, and project team members get access according to their roles.
|
||||
- **`publicRead`** - Object owner gets `OWNER` access, and `allUsers` get `READER` access.
|
||||
|
||||
##### config.private
|
||||
|
||||
- Type: `boolean`
|
||||
- *Optional*
|
||||
|
||||
Make the uploaded file private. (Alias for `config.predefinedAcl = 'private'`)
|
||||
|
||||
##### config.public
|
||||
|
||||
- Type: `boolean`
|
||||
- *Optional*
|
||||
|
||||
Make the uploaded file public. (Alias for `config.predefinedAcl = 'publicRead'`)
|
||||
|
||||
##### config.uri
|
||||
|
||||
- Type: `string`
|
||||
- *Optional*
|
||||
|
||||
If you already have a resumable URI from a previously-created resumable upload, just pass it in here and we'll use that.
|
||||
|
||||
##### config.userProject
|
||||
|
||||
- Type: `string`
|
||||
- *Optional*
|
||||
|
||||
If the bucket being accessed has `requesterPays` functionality enabled, this can be set to control which project is billed for the access of this file.
|
||||
|
||||
---
|
||||
<a name="events"></a>
|
||||
### Events
|
||||
|
||||
#### .on('error', function (err) {})
|
||||
|
||||
##### err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
Invoked if the authorization failed, the request failed, or the file wasn't successfully uploaded.
|
||||
|
||||
#### .on('response', function (response) {})
|
||||
|
||||
##### resp
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
The [response object from Gaxios](https://github.com/JustinBeckwith/gaxios/blob/88a47e000625d8192689acac5c40c0b1e1d963a2/src/gaxios.ts#L197-L203).
|
||||
|
||||
##### metadata
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
The file's new metadata.
|
||||
|
||||
#### .on('finish', function () {})
|
||||
|
||||
The file was uploaded successfully.
|
||||
|
||||
---
|
||||
<a name="static-methods"></a>
|
||||
### Static Methods
|
||||
|
||||
```js
|
||||
const {createURI} = require('gcs-resumable-upload')
|
||||
````
|
||||
|
||||
#### createURI([config](#config), callback)
|
||||
|
||||
##### callback(err, resumableURI)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
Invoked if the authorization failed or the request to start a resumable session failed.
|
||||
|
||||
###### callback.resumableURI
|
||||
|
||||
- Type: `String`
|
||||
|
||||
The resumable upload session URI.
|
17
node_modules/gcs-resumable-upload/build/src/cli.d.ts
generated
vendored
Normal file
17
node_modules/gcs-resumable-upload/build/src/cli.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env node
|
||||
/*!
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
34
node_modules/gcs-resumable-upload/build/src/cli.js
generated
vendored
Normal file
34
node_modules/gcs-resumable-upload/build/src/cli.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _1 = require(".");
|
||||
const args = process.argv.slice(2);
|
||||
const opts = {
|
||||
bucket: args[0],
|
||||
file: args[1],
|
||||
};
|
||||
process.stdin
|
||||
.pipe(_1.upload(opts))
|
||||
.on('error', console.error)
|
||||
.on('response', (resp, metadata) => {
|
||||
if (!metadata || !metadata.mediaLink)
|
||||
return;
|
||||
console.log('uploaded!');
|
||||
console.log(metadata.mediaLink);
|
||||
});
|
||||
//# sourceMappingURL=cli.js.map
|
1
node_modules/gcs-resumable-upload/build/src/cli.js.map
generated
vendored
Normal file
1
node_modules/gcs-resumable-upload/build/src/cli.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;GAcG;;AAEH,wBAAyB;AAEzB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,IAAI,GAAG;IACX,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IACf,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;CACd,CAAC;AAEF,OAAO,CAAC,KAAK;KACV,IAAI,CAAC,SAAM,CAAC,IAAI,CAAC,CAAC;KAClB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;KAC1B,EAAE,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;IACjC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,SAAS;QAAE,OAAO;IAC7C,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
191
node_modules/gcs-resumable-upload/build/src/index.d.ts
generated
vendored
Normal file
191
node_modules/gcs-resumable-upload/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
/*!
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import * as ConfigStore from 'configstore';
|
||||
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
|
||||
import * as Pumpify from 'pumpify';
|
||||
export interface ErrorWithCode extends Error {
|
||||
code: number;
|
||||
}
|
||||
export declare type CreateUriCallback = (err: Error | null, uri?: string) => void;
|
||||
export interface Encryption {
|
||||
key: {};
|
||||
hash: {};
|
||||
}
|
||||
export declare type PredefinedAcl = 'authenticatedRead' | 'bucketOwnerFullControl' | 'bucketOwnerRead' | 'private' | 'projectPrivate' | 'publicRead';
|
||||
export interface QueryParameters {
|
||||
contentEncoding?: string;
|
||||
ifGenerationMatch?: number;
|
||||
ifGenerationNotMatch?: number;
|
||||
ifMetagenerationMatch?: number;
|
||||
ifMetagenerationNotMatch?: number;
|
||||
kmsKeyName?: string;
|
||||
predefinedAcl?: PredefinedAcl;
|
||||
projection?: 'full' | 'noAcl';
|
||||
userProject?: string;
|
||||
}
|
||||
export interface UploadConfig {
|
||||
/**
|
||||
* The API endpoint used for the request.
|
||||
* Defaults to `storage.googleapis.com`.
|
||||
*/
|
||||
apiEndpoint?: string;
|
||||
/**
|
||||
* The name of the destination bucket.
|
||||
*/
|
||||
bucket: string;
|
||||
/**
|
||||
* The name of the destination file.
|
||||
*/
|
||||
file: string;
|
||||
/**
|
||||
* The GoogleAuthOptions passed to google-auth-library
|
||||
*/
|
||||
authConfig?: GoogleAuthOptions;
|
||||
/**
|
||||
* If you want to re-use an auth client from google-auto-auth, pass an
|
||||
* instance here.
|
||||
*/
|
||||
authClient?: GoogleAuth;
|
||||
/**
|
||||
* Where the gcs-resumable-upload configuration file should be stored on your
|
||||
* system. This maps to the configstore option by the same name.
|
||||
*/
|
||||
configPath?: string;
|
||||
/**
|
||||
* This will cause the upload to fail if the current generation of the remote
|
||||
* object does not match the one provided here.
|
||||
*/
|
||||
generation?: number;
|
||||
/**
|
||||
* A customer-supplied encryption key. See
|
||||
* https://cloud.google.com/storage/docs/encryption#customer-supplied.
|
||||
*/
|
||||
key?: string | Buffer;
|
||||
/**
|
||||
* Resource name of the Cloud KMS key, of the form
|
||||
* `projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key`,
|
||||
* that will be used to encrypt the object. Overrides the object metadata's
|
||||
* `kms_key_name` value, if any.
|
||||
*/
|
||||
kmsKeyName?: string;
|
||||
/**
|
||||
* Any metadata you wish to set on the object.
|
||||
*/
|
||||
metadata?: ConfigMetadata;
|
||||
/**
|
||||
* The starting byte of the upload stream, for resuming an interrupted upload.
|
||||
* See
|
||||
* https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload#resume-upload.
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Set an Origin header when creating the resumable upload URI.
|
||||
*/
|
||||
origin?: string;
|
||||
/**
|
||||
* Specify query parameters that go along with the initial upload request. See
|
||||
* https://cloud.google.com/storage/docs/json_api/v1/objects/insert#parameters
|
||||
*/
|
||||
params?: QueryParameters;
|
||||
/**
|
||||
* Apply a predefined set of access controls to the created file.
|
||||
*/
|
||||
predefinedAcl?: PredefinedAcl;
|
||||
/**
|
||||
* Make the uploaded file private. (Alias for config.predefinedAcl =
|
||||
* 'private')
|
||||
*/
|
||||
private?: boolean;
|
||||
/**
|
||||
* Make the uploaded file public. (Alias for config.predefinedAcl =
|
||||
* 'publicRead')
|
||||
*/
|
||||
public?: boolean;
|
||||
/**
|
||||
* If you already have a resumable URI from a previously-created resumable
|
||||
* upload, just pass it in here and we'll use that.
|
||||
*/
|
||||
uri?: string;
|
||||
/**
|
||||
* If the bucket being accessed has requesterPays functionality enabled, this
|
||||
* can be set to control which project is billed for the access of this file.
|
||||
*/
|
||||
userProject?: string;
|
||||
}
|
||||
export interface ConfigMetadata {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* Set the length of the file being uploaded.
|
||||
*/
|
||||
contentLength?: number;
|
||||
/**
|
||||
* Set the content type of the incoming data.
|
||||
*/
|
||||
contentType?: string;
|
||||
}
|
||||
export declare class Upload extends Pumpify {
|
||||
bucket: string;
|
||||
file: string;
|
||||
apiEndpoint: string;
|
||||
authConfig?: {
|
||||
scopes?: string[];
|
||||
};
|
||||
authClient: GoogleAuth;
|
||||
cacheKey: string;
|
||||
generation?: number;
|
||||
key?: string | Buffer;
|
||||
kmsKeyName?: string;
|
||||
metadata: ConfigMetadata;
|
||||
offset?: number;
|
||||
origin?: string;
|
||||
params: QueryParameters;
|
||||
predefinedAcl?: PredefinedAcl;
|
||||
private?: boolean;
|
||||
public?: boolean;
|
||||
uri?: string;
|
||||
userProject?: string;
|
||||
encryption?: Encryption;
|
||||
configStore: ConfigStore;
|
||||
uriProvidedManually: boolean;
|
||||
numBytesWritten: number;
|
||||
numRetries: number;
|
||||
contentLength: number | '*';
|
||||
private bufferStream?;
|
||||
private offsetStream?;
|
||||
private readonly baseURI;
|
||||
constructor(cfg: UploadConfig);
|
||||
createURI(): Promise<string>;
|
||||
createURI(callback: CreateUriCallback): void;
|
||||
protected createURIAsync(): Promise<string>;
|
||||
private continueUploading;
|
||||
private startUploading;
|
||||
private onChunk;
|
||||
private getAndSetOffset;
|
||||
private makeRequest;
|
||||
private makeRequestStream;
|
||||
private restart;
|
||||
private get;
|
||||
private set;
|
||||
deleteConfig(): void;
|
||||
/**
|
||||
* @return {bool} is the request good?
|
||||
*/
|
||||
private onResponse;
|
||||
}
|
||||
export declare function upload(cfg: UploadConfig): Upload;
|
||||
export declare function createURI(cfg: UploadConfig): Promise<string>;
|
||||
export declare function createURI(cfg: UploadConfig, callback: CreateUriCallback): void;
|
400
node_modules/gcs-resumable-upload/build/src/index.js
generated
vendored
Normal file
400
node_modules/gcs-resumable-upload/build/src/index.js
generated
vendored
Normal file
@ -0,0 +1,400 @@
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const abort_controller_1 = require("abort-controller");
|
||||
const ConfigStore = require("configstore");
|
||||
const crypto_1 = require("crypto");
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
const Pumpify = require("pumpify");
|
||||
const stream_1 = require("stream");
|
||||
const streamEvents = require("stream-events");
|
||||
const TERMINATED_UPLOAD_STATUS_CODE = 410;
|
||||
const RESUMABLE_INCOMPLETE_STATUS_CODE = 308;
|
||||
const RETRY_LIMIT = 5;
|
||||
class Upload extends Pumpify {
|
||||
constructor(cfg) {
|
||||
super();
|
||||
this.numBytesWritten = 0;
|
||||
this.numRetries = 0;
|
||||
streamEvents(this);
|
||||
cfg = cfg || {};
|
||||
if (!cfg.bucket || !cfg.file) {
|
||||
throw new Error('A bucket and file name are required');
|
||||
}
|
||||
cfg.authConfig = cfg.authConfig || {};
|
||||
cfg.authConfig.scopes = [
|
||||
'https://www.googleapis.com/auth/devstorage.full_control',
|
||||
];
|
||||
this.authClient = cfg.authClient || new google_auth_library_1.GoogleAuth(cfg.authConfig);
|
||||
this.apiEndpoint = cfg.apiEndpoint || 'storage.googleapis.com';
|
||||
this.bucket = cfg.bucket;
|
||||
const cacheKeyElements = [cfg.bucket, cfg.file];
|
||||
if (typeof cfg.generation === 'number') {
|
||||
cacheKeyElements.push(`${cfg.generation}`);
|
||||
}
|
||||
this.cacheKey = cacheKeyElements.join('/');
|
||||
this.file = cfg.file;
|
||||
this.generation = cfg.generation;
|
||||
this.kmsKeyName = cfg.kmsKeyName;
|
||||
this.metadata = cfg.metadata || {};
|
||||
this.offset = cfg.offset;
|
||||
this.origin = cfg.origin;
|
||||
this.params = cfg.params || {};
|
||||
this.userProject = cfg.userProject;
|
||||
if (cfg.key) {
|
||||
/**
|
||||
* NOTE: This is `as string` because there appears to be some weird kind
|
||||
* of TypeScript bug as 2.8. Tracking the issue here:
|
||||
* https://github.com/Microsoft/TypeScript/issues/23155
|
||||
*/
|
||||
const base64Key = Buffer.from(cfg.key).toString('base64');
|
||||
this.encryption = {
|
||||
key: base64Key,
|
||||
hash: crypto_1.createHash('sha256')
|
||||
.update(cfg.key)
|
||||
.digest('base64'),
|
||||
};
|
||||
}
|
||||
this.predefinedAcl = cfg.predefinedAcl;
|
||||
if (cfg.private)
|
||||
this.predefinedAcl = 'private';
|
||||
if (cfg.public)
|
||||
this.predefinedAcl = 'publicRead';
|
||||
const configPath = cfg.configPath;
|
||||
this.configStore = new ConfigStore('gcs-resumable-upload', null, {
|
||||
configPath,
|
||||
});
|
||||
this.uriProvidedManually = !!cfg.uri;
|
||||
this.uri = cfg.uri || this.get('uri');
|
||||
this.numBytesWritten = 0;
|
||||
this.numRetries = 0;
|
||||
const contentLength = cfg.metadata
|
||||
? Number(cfg.metadata.contentLength)
|
||||
: NaN;
|
||||
this.contentLength = isNaN(contentLength) ? '*' : contentLength;
|
||||
this.once('writing', () => {
|
||||
if (this.uri) {
|
||||
this.continueUploading();
|
||||
}
|
||||
else {
|
||||
this.createURI(err => {
|
||||
if (err) {
|
||||
return this.destroy(err);
|
||||
}
|
||||
this.startUploading();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
get baseURI() {
|
||||
return `https://${this.apiEndpoint}/upload/storage/v1/b`;
|
||||
}
|
||||
createURI(callback) {
|
||||
if (!callback) {
|
||||
return this.createURIAsync();
|
||||
}
|
||||
this.createURIAsync().then(r => callback(null, r), callback);
|
||||
}
|
||||
async createURIAsync() {
|
||||
const metadata = this.metadata;
|
||||
const reqOpts = {
|
||||
method: 'POST',
|
||||
url: [this.baseURI, this.bucket, 'o'].join('/'),
|
||||
params: Object.assign({
|
||||
name: this.file,
|
||||
uploadType: 'resumable',
|
||||
}, this.params),
|
||||
data: metadata,
|
||||
headers: {},
|
||||
};
|
||||
if (metadata.contentLength) {
|
||||
reqOpts.headers['X-Upload-Content-Length'] = metadata.contentLength.toString();
|
||||
}
|
||||
if (metadata.contentType) {
|
||||
reqOpts.headers['X-Upload-Content-Type'] = metadata.contentType;
|
||||
}
|
||||
if (typeof this.generation !== 'undefined') {
|
||||
reqOpts.params.ifGenerationMatch = this.generation;
|
||||
}
|
||||
if (this.kmsKeyName) {
|
||||
reqOpts.params.kmsKeyName = this.kmsKeyName;
|
||||
}
|
||||
if (this.predefinedAcl) {
|
||||
reqOpts.params.predefinedAcl = this.predefinedAcl;
|
||||
}
|
||||
if (this.origin) {
|
||||
reqOpts.headers.Origin = this.origin;
|
||||
}
|
||||
const resp = await this.makeRequest(reqOpts);
|
||||
const uri = resp.headers.location;
|
||||
this.uri = uri;
|
||||
this.set({ uri });
|
||||
this.offset = 0;
|
||||
return uri;
|
||||
}
|
||||
async continueUploading() {
|
||||
if (typeof this.offset === 'number') {
|
||||
this.startUploading();
|
||||
return;
|
||||
}
|
||||
await this.getAndSetOffset();
|
||||
this.startUploading();
|
||||
}
|
||||
async startUploading() {
|
||||
// The buffer stream allows us to keep chunks in memory
|
||||
// until we are sure we can successfully resume the upload.
|
||||
const bufferStream = this.bufferStream || new stream_1.PassThrough();
|
||||
this.bufferStream = bufferStream;
|
||||
// The offset stream allows us to analyze each incoming
|
||||
// chunk to analyze it against what the upstream API already
|
||||
// has stored for this upload.
|
||||
const offsetStream = (this.offsetStream = new stream_1.Transform({
|
||||
transform: this.onChunk.bind(this),
|
||||
}));
|
||||
// The delay stream gives us a chance to catch the response
|
||||
// from the API request before we signal to the user that
|
||||
// the upload was successful.
|
||||
const delayStream = new stream_1.PassThrough();
|
||||
// The request library (authClient.request()) requires the
|
||||
// stream to be sent within the request options.
|
||||
const requestStreamEmbeddedStream = new stream_1.PassThrough();
|
||||
delayStream.on('prefinish', () => {
|
||||
// Pause the stream from finishing so we can process the
|
||||
// response from the API.
|
||||
this.cork();
|
||||
});
|
||||
// Process the API response to look for errors that came in
|
||||
// the response body.
|
||||
this.on('response', (resp) => {
|
||||
if (resp.data.error) {
|
||||
this.destroy(resp.data.error);
|
||||
return;
|
||||
}
|
||||
if (resp.status < 200 || resp.status > 299) {
|
||||
this.destroy(new Error('Upload failed'));
|
||||
return;
|
||||
}
|
||||
if (resp && resp.data) {
|
||||
resp.data.size = Number(resp.data.size);
|
||||
}
|
||||
this.emit('metadata', resp.data);
|
||||
this.deleteConfig();
|
||||
// Allow the stream to continue naturally so the user's
|
||||
// "finish" event fires.
|
||||
this.uncork();
|
||||
});
|
||||
this.setPipeline(bufferStream, offsetStream, delayStream);
|
||||
this.pipe(requestStreamEmbeddedStream);
|
||||
this.once('restart', () => {
|
||||
// The upload is being re-attempted. Disconnect the request
|
||||
// stream, so it won't receive more data.
|
||||
this.unpipe(requestStreamEmbeddedStream);
|
||||
});
|
||||
const reqOpts = {
|
||||
method: 'PUT',
|
||||
url: this.uri,
|
||||
headers: {
|
||||
'Content-Range': 'bytes ' + this.offset + '-*/' + this.contentLength,
|
||||
},
|
||||
body: requestStreamEmbeddedStream,
|
||||
};
|
||||
try {
|
||||
await this.makeRequestStream(reqOpts);
|
||||
}
|
||||
catch (e) {
|
||||
this.destroy(e);
|
||||
}
|
||||
}
|
||||
onChunk(chunk, enc, next) {
|
||||
const offset = this.offset;
|
||||
const numBytesWritten = this.numBytesWritten;
|
||||
this.emit('progress', {
|
||||
bytesWritten: this.numBytesWritten,
|
||||
contentLength: this.contentLength,
|
||||
});
|
||||
// check if this is the same content uploaded previously. this caches a
|
||||
// slice of the first chunk, then compares it with the first byte of
|
||||
// incoming data
|
||||
if (numBytesWritten === 0) {
|
||||
let cachedFirstChunk = this.get('firstChunk');
|
||||
const firstChunk = chunk.slice(0, 16).valueOf();
|
||||
if (!cachedFirstChunk) {
|
||||
// This is a new upload. Cache the first chunk.
|
||||
this.set({ uri: this.uri, firstChunk });
|
||||
}
|
||||
else {
|
||||
// this continues an upload in progress. check if the bytes are the same
|
||||
cachedFirstChunk = Buffer.from(cachedFirstChunk);
|
||||
const nextChunk = Buffer.from(firstChunk);
|
||||
if (Buffer.compare(cachedFirstChunk, nextChunk) !== 0) {
|
||||
// this data is not the same. start a new upload
|
||||
this.bufferStream.unshift(chunk);
|
||||
this.bufferStream.unpipe(this.offsetStream);
|
||||
this.restart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let length = chunk.length;
|
||||
if (typeof chunk === 'string')
|
||||
length = Buffer.byteLength(chunk, enc);
|
||||
if (numBytesWritten < offset)
|
||||
chunk = chunk.slice(offset - numBytesWritten);
|
||||
this.numBytesWritten += length;
|
||||
// only push data from the byte after the one we left off on
|
||||
next(undefined, this.numBytesWritten > offset ? chunk : undefined);
|
||||
}
|
||||
async getAndSetOffset() {
|
||||
const opts = {
|
||||
method: 'PUT',
|
||||
url: this.uri,
|
||||
headers: { 'Content-Length': 0, 'Content-Range': 'bytes */*' },
|
||||
};
|
||||
try {
|
||||
const resp = await this.makeRequest(opts);
|
||||
if (resp.status === RESUMABLE_INCOMPLETE_STATUS_CODE) {
|
||||
if (resp.headers.range) {
|
||||
const range = resp.headers.range;
|
||||
this.offset = Number(range.split('-')[1]) + 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.offset = 0;
|
||||
}
|
||||
catch (err) {
|
||||
const resp = err.response;
|
||||
// we don't return a 404 to the user if they provided the resumable
|
||||
// URI. if we're just using the configstore file to tell us that this
|
||||
// file exists, and it turns out that it doesn't (the 404), that's
|
||||
// probably stale config data.
|
||||
if (resp && resp.status === 404 && !this.uriProvidedManually) {
|
||||
this.restart();
|
||||
return;
|
||||
}
|
||||
// this resumable upload is unrecoverable (bad data or service error).
|
||||
// -
|
||||
// https://github.com/stephenplusplus/gcs-resumable-upload/issues/15
|
||||
// -
|
||||
// https://github.com/stephenplusplus/gcs-resumable-upload/pull/16#discussion_r80363774
|
||||
if (resp && resp.status === TERMINATED_UPLOAD_STATUS_CODE) {
|
||||
this.restart();
|
||||
return;
|
||||
}
|
||||
this.destroy(err);
|
||||
}
|
||||
}
|
||||
async makeRequest(reqOpts) {
|
||||
if (this.encryption) {
|
||||
reqOpts.headers = reqOpts.headers || {};
|
||||
reqOpts.headers['x-goog-encryption-algorithm'] = 'AES256';
|
||||
reqOpts.headers['x-goog-encryption-key'] = this.encryption.key.toString();
|
||||
reqOpts.headers['x-goog-encryption-key-sha256'] = this.encryption.hash.toString();
|
||||
}
|
||||
if (this.userProject) {
|
||||
reqOpts.params = reqOpts.params || {};
|
||||
reqOpts.params.userProject = this.userProject;
|
||||
}
|
||||
// Let gaxios know we will handle a 308 error code ourselves.
|
||||
reqOpts.validateStatus = (status) => {
|
||||
return ((status >= 200 && status < 300) ||
|
||||
status === RESUMABLE_INCOMPLETE_STATUS_CODE);
|
||||
};
|
||||
const res = await this.authClient.request(reqOpts);
|
||||
if (res.data && res.data.error) {
|
||||
throw res.data.error;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
async makeRequestStream(reqOpts) {
|
||||
const controller = new abort_controller_1.default();
|
||||
this.once('error', () => controller.abort());
|
||||
if (this.userProject) {
|
||||
reqOpts.params = reqOpts.params || {};
|
||||
reqOpts.params.userProject = this.userProject;
|
||||
}
|
||||
reqOpts.signal = controller.signal;
|
||||
reqOpts.validateStatus = () => true;
|
||||
const res = await this.authClient.request(reqOpts);
|
||||
this.onResponse(res);
|
||||
return res;
|
||||
}
|
||||
restart() {
|
||||
this.emit('restart');
|
||||
this.numBytesWritten = 0;
|
||||
this.deleteConfig();
|
||||
this.createURI(err => {
|
||||
if (err) {
|
||||
return this.destroy(err);
|
||||
}
|
||||
this.startUploading();
|
||||
});
|
||||
}
|
||||
get(prop) {
|
||||
const store = this.configStore.get(this.cacheKey);
|
||||
return store && store[prop];
|
||||
}
|
||||
// tslint:disable-next-line no-any
|
||||
set(props) {
|
||||
this.configStore.set(this.cacheKey, props);
|
||||
}
|
||||
deleteConfig() {
|
||||
this.configStore.delete(this.cacheKey);
|
||||
}
|
||||
/**
|
||||
* @return {bool} is the request good?
|
||||
*/
|
||||
onResponse(resp) {
|
||||
if (resp.status === 404) {
|
||||
if (this.numRetries < RETRY_LIMIT) {
|
||||
this.numRetries++;
|
||||
this.startUploading();
|
||||
}
|
||||
else {
|
||||
this.destroy(new Error('Retry limit exceeded - ' + resp.data));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (resp.status > 499 && resp.status < 600) {
|
||||
if (this.numRetries < RETRY_LIMIT) {
|
||||
const randomMs = Math.round(Math.random() * 1000);
|
||||
const waitTime = Math.pow(2, this.numRetries) * 1000 + randomMs;
|
||||
this.numRetries++;
|
||||
setTimeout(this.continueUploading.bind(this), waitTime);
|
||||
}
|
||||
else {
|
||||
this.destroy(new Error('Retry limit exceeded - ' + resp.data));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.emit('response', resp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.Upload = Upload;
|
||||
function upload(cfg) {
|
||||
return new Upload(cfg);
|
||||
}
|
||||
exports.upload = upload;
|
||||
function createURI(cfg, callback) {
|
||||
const up = new Upload(cfg);
|
||||
if (!callback) {
|
||||
return up.createURI();
|
||||
}
|
||||
up.createURI().then(r => callback(null, r), callback);
|
||||
}
|
||||
exports.createURI = createURI;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/gcs-resumable-upload/build/src/index.js.map
generated
vendored
Normal file
1
node_modules/gcs-resumable-upload/build/src/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
110
node_modules/gcs-resumable-upload/package.json
generated
vendored
Normal file
110
node_modules/gcs-resumable-upload/package.json
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
{
|
||||
"_from": "gcs-resumable-upload@^2.2.4",
|
||||
"_id": "gcs-resumable-upload@2.3.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-OPS0iAmPCV+r7PziOIhyxmQOzsazFCy76yYDOS/Z80O/7cuny1KMfqDQa2T0jLaL8EreTU7EMZG5pUuqBKgzHA==",
|
||||
"_location": "/gcs-resumable-upload",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "gcs-resumable-upload@^2.2.4",
|
||||
"name": "gcs-resumable-upload",
|
||||
"escapedName": "gcs-resumable-upload",
|
||||
"rawSpec": "^2.2.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.2.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@google-cloud/storage"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gcs-resumable-upload/-/gcs-resumable-upload-2.3.2.tgz",
|
||||
"_shasum": "f04a7459483f871f0de71db7454296938688a296",
|
||||
"_spec": "gcs-resumable-upload@^2.2.4",
|
||||
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix\\node_modules\\@google-cloud\\storage",
|
||||
"author": {
|
||||
"name": "Stephen Sawchuk",
|
||||
"email": "sawchuk@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"gcs-upload": "build/src/cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/googleapis/gcs-resumable-upload/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"abort-controller": "^3.0.0",
|
||||
"configstore": "^5.0.0",
|
||||
"gaxios": "^2.0.0",
|
||||
"google-auth-library": "^5.0.0",
|
||||
"pumpify": "^2.0.0",
|
||||
"stream-events": "^1.0.4"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Upload a file to Google Cloud Storage with built-in resumable behavior",
|
||||
"devDependencies": {
|
||||
"@compodoc/compodoc": "^1.1.7",
|
||||
"@types/configstore": "^4.0.0",
|
||||
"@types/is-stream": "^1.1.0",
|
||||
"@types/mocha": "^5.2.1",
|
||||
"@types/mockery": "^1.4.29",
|
||||
"@types/nock": "^10.0.0",
|
||||
"@types/node": "^10.3.0",
|
||||
"@types/pumpify": "^1.4.1",
|
||||
"@types/sinon": "^7.0.10",
|
||||
"assert-rejects": "^1.0.0",
|
||||
"c8": "^6.0.0",
|
||||
"codecov": "^3.0.4",
|
||||
"gts": "^1.0.0",
|
||||
"intelli-espower-loader": "^1.0.1",
|
||||
"is-stream": "^2.0.0",
|
||||
"linkinator": "^1.5.0",
|
||||
"mocha": "^6.1.4",
|
||||
"mockery": "^2.1.0",
|
||||
"nock": "^11.0.0",
|
||||
"sinon": "^7.3.2",
|
||||
"source-map-support": "^0.5.6",
|
||||
"typescript": "3.6.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.10.0"
|
||||
},
|
||||
"files": [
|
||||
"build/src"
|
||||
],
|
||||
"homepage": "https://github.com/googleapis/gcs-resumable-upload#readme",
|
||||
"keywords": [
|
||||
"google",
|
||||
"gcloud",
|
||||
"storage",
|
||||
"gcs",
|
||||
"upload",
|
||||
"resumable"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "build/src/index.js",
|
||||
"name": "gcs-resumable-upload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/googleapis/gcs-resumable-upload.git"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "gts clean",
|
||||
"compile": "tsc -p .",
|
||||
"docs": "compodoc src/",
|
||||
"docs-test": "linkinator docs",
|
||||
"fix": "gts fix",
|
||||
"lint": "gts check",
|
||||
"posttest": "npm run lint",
|
||||
"predocs-test": "npm run docs",
|
||||
"prepare": "npm run compile",
|
||||
"presystem-test": "npm run compile",
|
||||
"pretest": "npm run compile",
|
||||
"samples-test": "echo no samples 🤷♂️",
|
||||
"system-test": "mocha build/system-test --timeout 20000",
|
||||
"test": "c8 mocha build/test"
|
||||
},
|
||||
"types": "build/src/index.d.ts",
|
||||
"version": "2.3.2"
|
||||
}
|
Reference in New Issue
Block a user