From 08e0e2fa5756fb7901a8280a9b2d504a96439aee Mon Sep 17 00:00:00 2001 From: Abhilash Murthy Date: Tue, 13 Nov 2018 18:06:15 +0800 Subject: [PATCH] update to use @google-cloud/storage --- index.js | 28 ++++++++++++++-------------- package.json | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 0b72999..918bab6 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,6 @@ "use strict"; -let gcloud = require('gcloud'); - -let storage = gcloud.storage(); +const { Storage } = require('@google-cloud/storage'); const DEFAULT_POLL_TIME = 3 * 1000; @@ -22,18 +20,20 @@ class GCSNotifier { } getLastModified() { - let file = storage.bucket(this.bucket).file(this.key); - - return new Promise(function(resolve, reject){ - file.get(function(err, file, apiResponse){ - if (err) { - reject(err); - } - resolve(apiResponse.updated); - }); + let storage = new Storage(); + let bucket = storage.bucket(this.bucket); + let file = bucket.file(this.key); + + return new Promise(function(resolve, reject){ + file.get(function(err, file, apiResponse){ + if (err) { + reject(err); + } + resolve(apiResponse.updated); }); + }); } - + getCurrentLastModified() { return this.getLastModified() .then(LastModified => { @@ -68,4 +68,4 @@ class GCSNotifier { } -module.exports = GCSNotifier; \ No newline at end of file +module.exports = GCSNotifier; diff --git a/package.json b/package.json index 75f1816..66bc2e8 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,6 @@ }, "homepage": "https://github.com/EmberSherpa/fastboot-gcloud-storage-notifier#readme", "dependencies": { - "gcloud": "0.32.0" + "@google-cloud/storage": "^2.3.0" } }