gcs-resumable-upload
Advanced tools
Comparing version
@@ -21,2 +21,7 @@ /** | ||
/** | ||
* The API endpoint used for the request. | ||
* Defaults to `storage.googleapis.com`. | ||
*/ | ||
apiEndpoint?: string; | ||
/** | ||
* The name of the destination bucket. | ||
@@ -29,2 +34,5 @@ */ | ||
file: string; | ||
/** | ||
* The GoogleAuthOptions passed to google-auth-library | ||
*/ | ||
authConfig?: GoogleAuthOptions; | ||
@@ -110,2 +118,3 @@ /** | ||
file: string; | ||
apiEndpoint: string; | ||
authConfig?: { | ||
@@ -134,2 +143,3 @@ scopes?: string[]; | ||
private offsetStream?; | ||
private readonly baseURI; | ||
constructor(cfg: UploadConfig); | ||
@@ -136,0 +146,0 @@ createURI(): Promise<string>; |
@@ -16,3 +16,2 @@ "use strict"; | ||
const streamEvents = require("stream-events"); | ||
const BASE_URI = 'https://www.googleapis.com/upload/storage/v1/b'; | ||
const TERMINATED_UPLOAD_STATUS_CODE = 410; | ||
@@ -36,2 +35,3 @@ const RESUMABLE_INCOMPLETE_STATUS_CODE = 308; | ||
this.authClient = cfg.authClient || new google_auth_library_1.GoogleAuth(cfg.authConfig); | ||
this.apiEndpoint = cfg.apiEndpoint || 'storage.googleapis.com'; | ||
this.bucket = cfg.bucket; | ||
@@ -88,2 +88,5 @@ this.file = cfg.file; | ||
} | ||
get baseURI() { | ||
return `https://${this.apiEndpoint}/upload/storage/v1/b`; | ||
} | ||
createURI(callback) { | ||
@@ -99,3 +102,3 @@ if (!callback) { | ||
method: 'POST', | ||
url: [BASE_URI, this.bucket, 'o'].join('/'), | ||
url: [this.baseURI, this.bucket, 'o'].join('/'), | ||
params: { name: this.file, uploadType: 'resumable' }, | ||
@@ -102,0 +105,0 @@ data: metadata, |
@@ -7,2 +7,9 @@ # Changelog | ||
## [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) | ||
@@ -9,0 +16,0 @@ |
{ | ||
"name": "gcs-resumable-upload", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Upload a file to Google Cloud Storage with built-in resumable behavior", | ||
@@ -12,3 +12,3 @@ "repository": "googleapis/gcs-resumable-upload", | ||
"scripts": { | ||
"test": "nyc mocha build/test", | ||
"test": "c8 mocha build/test", | ||
"lint": "gts check", | ||
@@ -25,3 +25,3 @@ "clean": "gts clean", | ||
"docs": "compodoc src/", | ||
"docs-test": "linkinator docs -r --skip www.googleapis.com", | ||
"docs-test": "linkinator docs -r", | ||
"predocs-test": "npm run docs" | ||
@@ -63,2 +63,3 @@ }, | ||
"assert-rejects": "^1.0.0", | ||
"c8": "^5.0.1", | ||
"codecov": "^3.0.4", | ||
@@ -72,6 +73,5 @@ "gts": "^1.0.0", | ||
"nock": "^10.0.0", | ||
"nyc": "^14.0.0", | ||
"source-map-support": "^0.5.6", | ||
"typescript": "~3.4.0" | ||
"typescript": "~3.5.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
52448
1.45%573
2.32%