|
@@ -2,8 +2,8 @@ import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:service:fileUploaderAws');
|
|
const logger = loggerFactory('growi:service:fileUploaderAws');
|
|
|
|
|
|
|
|
-const urljoin = require('url-join');
|
|
|
|
|
const { Storage } = require('@google-cloud/storage');
|
|
const { Storage } = require('@google-cloud/storage');
|
|
|
|
|
+const urljoin = require('url-join');
|
|
|
|
|
|
|
|
let _instance;
|
|
let _instance;
|
|
|
|
|
|
|
@@ -21,7 +21,9 @@ module.exports = function(crowi) {
|
|
|
if (_instance == null) {
|
|
if (_instance == null) {
|
|
|
const keyFilename = configManager.getConfig('crowi', 'gcs:apiKeyJsonPath');
|
|
const keyFilename = configManager.getConfig('crowi', 'gcs:apiKeyJsonPath');
|
|
|
// see https://googleapis.dev/nodejs/storage/latest/Storage.html
|
|
// see https://googleapis.dev/nodejs/storage/latest/Storage.html
|
|
|
- _instance = new Storage({ keyFilename });
|
|
|
|
|
|
|
+ _instance = keyFilename != null
|
|
|
|
|
+ ? new Storage({ keyFilename }) // Create a client with explicit credentials
|
|
|
|
|
+ : new Storage(); // Create a client that uses Application Default Credentials
|
|
|
}
|
|
}
|
|
|
return _instance;
|
|
return _instance;
|
|
|
}
|
|
}
|