Skip to content

Commit 672b116

Browse files
committed
Use alternate Storage.Object.get API URL pattern to avoid SSL certificated error if there are '.' in the bucket name
1 parent 1c81c27 commit 672b116

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Patrick Costello <pcostell@google.com>
1818
Silvano Luciani <silvano@google.com>
1919
Stephen Sawchuk <sawchuk@gmail.com>
2020
Anand Suresh <anandsuresh@gmail.com>
21+
Stephen Zhang <stephen.zsy@gmail.com>

lib/storage/file.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ File.prototype.createReadStream = function(options) {
426426
b: this.bucket.name,
427427
o: encodeURIComponent(this.name)
428428
});
429+
if(this.bucket.name.indexOf('.') >= 0) {
430+
// certificate error if bucket name contains dot, use JSONv1 API
431+
remoteFilePath = util.format(
432+
'https://www.googleapis.com/storage/v1/b/{b}/o/{o}?alt=media', {
433+
b: this.bucket.name,
434+
o: encodeURIComponent(this.name)
435+
});
436+
}
429437

430438
createAuthorizedReq(remoteFilePath);
431439

0 commit comments

Comments
 (0)