thorin-plugin-upload-gcloud 2.0.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/store.js CHANGED
@@ -180,6 +180,7 @@ module.exports = function (thorin, opt, IStorage) {
180
180
  fopt.key = fileUrl;
181
181
  }
182
182
  if (!fopt.bucket) fopt.bucket = this[config].bucket;
183
+ if (fopt.key?.startsWith('/')) fopt.key = fopt.key.substr(1);
183
184
  return new Promise((resolve, reject) => {
184
185
  const bucketObj = this[sdk].bucket(fopt.bucket);
185
186
  let sFileObj = new File(bucketObj, fopt.key);
@@ -205,7 +206,10 @@ module.exports = function (thorin, opt, IStorage) {
205
206
  function onData(d) {
206
207
  if (isDone) return;
207
208
  isDone = true;
208
- if (!contentType) return resolve(d);
209
+ if (!contentType) {
210
+ d._file = sFileObj;
211
+ return resolve(d);
212
+ }
209
213
  let isString = false;
210
214
  if (contentType.indexOf('text/') !== -1) {
211
215
  isString = true;
@@ -215,6 +219,8 @@ module.exports = function (thorin, opt, IStorage) {
215
219
  isString = true;
216
220
  }
217
221
  if (isString) d = d.toString();
222
+ d._contentType = contentType;
223
+ d._file = sFileObj;
218
224
  resolve(d);
219
225
  }
220
226
 
@@ -258,6 +264,9 @@ module.exports = function (thorin, opt, IStorage) {
258
264
  let expireAt = new Date(Date.now() + opt.expire * 1000);
259
265
  fOpt.expires = expireAt.toISOString();
260
266
  }
267
+ if (fileObj.name.charAt(0) === '/') {
268
+ fileObj.name = fileObj.name.substr(1);
269
+ }
261
270
  fileObj.getSignedUrl(fOpt, (err, url) => {
262
271
  if (err) {
263
272
  logger.debug(`Could not generate signed URL for: ${params.Key}-${params.Bucket}`);
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "thorin-plugin-upload-gcloud",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "thorin-plugin-upload-gcloud",
9
- "version": "2.0.8",
9
+ "version": "2.0.10",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@google-cloud/storage": "^7.16.0",
12
+ "@google-cloud/storage": "7.17.3",
13
13
  "concat-stream": "2.0.0"
14
14
  }
15
15
  },
@@ -42,9 +42,9 @@
42
42
  }
43
43
  },
44
44
  "node_modules/@google-cloud/storage": {
45
- "version": "7.16.0",
46
- "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.16.0.tgz",
47
- "integrity": "sha512-7/5LRgykyOfQENcm6hDKP8SX/u9XxE5YOiWOkgkwcoO+cG8xT/cyOvp9wwN3IxfdYgpHs8CE7Nq2PKX2lNaEXw==",
45
+ "version": "7.17.3",
46
+ "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.17.3.tgz",
47
+ "integrity": "sha512-gOnCAbFgAYKRozywLsxagdevTF7Gm+2Ncz5u5CQAuOv/2VCa0rdGJWvJFDOftPx1tc+q8TXiC2pEJfFKu+yeMQ==",
48
48
  "license": "Apache-2.0",
49
49
  "dependencies": {
50
50
  "@google-cloud/paginator": "^5.0.0",
@@ -941,9 +941,9 @@
941
941
  "integrity": "sha512-Orxzlfb9c67A15cq2JQEyVc7wEsmFBmHjZWZYQMUyJ1qivXyMwdyNOs9odi79hze+2zqdTtu1E19IM/FtqZ10g=="
942
942
  },
943
943
  "@google-cloud/storage": {
944
- "version": "7.16.0",
945
- "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.16.0.tgz",
946
- "integrity": "sha512-7/5LRgykyOfQENcm6hDKP8SX/u9XxE5YOiWOkgkwcoO+cG8xT/cyOvp9wwN3IxfdYgpHs8CE7Nq2PKX2lNaEXw==",
944
+ "version": "7.17.3",
945
+ "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.17.3.tgz",
946
+ "integrity": "sha512-gOnCAbFgAYKRozywLsxagdevTF7Gm+2Ncz5u5CQAuOv/2VCa0rdGJWvJFDOftPx1tc+q8TXiC2pEJfFKu+yeMQ==",
947
947
  "requires": {
948
948
  "@google-cloud/paginator": "^5.0.0",
949
949
  "@google-cloud/projectify": "^4.0.0",
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "thorin-plugin-upload-gcloud",
3
3
  "author": "UNLOQ Systems",
4
- "version": "2.0.9",
4
+ "version": "2.0.11",
5
5
  "dependencies": {
6
- "@google-cloud/storage": "^7.16.0",
6
+ "@google-cloud/storage": "7.17.3",
7
7
  "concat-stream": "2.0.0"
8
8
  },
9
9
  "description": "Thorin.js Google Cloud Upload storage",
@@ -13,7 +13,7 @@
13
13
  "type": "git",
14
14
  "url": "https://github.com/Thorinjs/Thorin-plugin-upload-gcloud"
15
15
  },
16
- "homepage": "http://thorinjs.com",
16
+ "homepage": "https://thorinjs.com",
17
17
  "bugs": {
18
18
  "url": "https://github.com/Thorinjs/Thorin-plugin-upload-gcloud/issues"
19
19
  }