From 672b1162f1f43dd04efd8397f2ddc4b787171c16 Mon Sep 17 00:00:00 2001 From: Stephen Date: Sat, 23 May 2015 10:16:32 -0700 Subject: [PATCH] Use alternate Storage.Object.get API URL pattern to avoid SSL certificated error if there are '.' in the bucket name --- CONTRIBUTORS | 1 + lib/storage/file.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b6bb54b4ba1..4b723e39665 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -18,3 +18,4 @@ Patrick Costello Silvano Luciani Stephen Sawchuk Anand Suresh +Stephen Zhang diff --git a/lib/storage/file.js b/lib/storage/file.js index ba0d74a34c0..7d9e4f0bc9f 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -426,6 +426,14 @@ File.prototype.createReadStream = function(options) { b: this.bucket.name, o: encodeURIComponent(this.name) }); + if(this.bucket.name.indexOf('.') >= 0) { + // certificate error if bucket name contains dot, use JSONv1 API + remoteFilePath = util.format( + 'https://www.googleapis.com/storage/v1/b/{b}/o/{o}?alt=media', { + b: this.bucket.name, + o: encodeURIComponent(this.name) + }); + } createAuthorizedReq(remoteFilePath);