@8ms/helpers 1.3.16 → 1.3.17

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.
@@ -2,9 +2,10 @@ type CopyToCloud = {
2
2
  bucket: string;
3
3
  localFile: string;
4
4
  options?: object;
5
+ projectId?: string;
5
6
  };
6
7
  /**
7
8
  * Copy a local file to Google Cloud Storage.
8
9
  */
9
- export declare const copyToCloud: ({ bucket, localFile, options }: CopyToCloud) => Promise<any>;
10
+ export declare const copyToCloud: ({ bucket, localFile, options, projectId }: CopyToCloud) => Promise<any>;
10
11
  export default copyToCloud;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.copyToCloud = void 0;
7
+ const getClient_1 = __importDefault(require("./getClient"));
4
8
  /**
5
9
  * Copy a local file to Google Cloud Storage.
6
10
  */
7
- const copyToCloud = async ({ bucket, localFile, options }) => {
8
- const bucketInstance = global.googleStorageClient.bucket(bucket);
11
+ const copyToCloud = async ({ bucket, localFile, options, projectId }) => {
12
+ const bucketInstance = (0, getClient_1.default)({ projectId })
13
+ .bucket(bucket);
9
14
  const apiResponse = await bucketInstance.upload(localFile, options);
10
15
  return apiResponse;
11
16
  };
@@ -2,10 +2,11 @@ type WriteFile = {
2
2
  bucket: string;
3
3
  data: any;
4
4
  key: string;
5
+ projectId?: string;
5
6
  [options: string]: any;
6
7
  };
7
8
  /**
8
9
  * Write a file to Google Cloud Storage.
9
10
  */
10
- export declare const writeFile: ({ bucket, contentType, data, key, ...options }: WriteFile) => Promise<any>;
11
+ export declare const writeFile: ({ bucket, contentType, data, key, projectId, ...options }: WriteFile) => Promise<any>;
11
12
  export default writeFile;
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.writeFile = void 0;
7
+ const getClient_1 = __importDefault(require("./getClient"));
4
8
  /**
5
9
  * Write a file to Google Cloud Storage.
6
10
  */
7
- const writeFile = async ({ bucket, contentType, data, key, ...options }) => {
11
+ const writeFile = async ({ bucket, contentType, data, key, projectId, ...options }) => {
8
12
  const stream = require('stream');
9
13
  const dataStream = new stream.PassThrough();
10
- const googleFile = global.googleStorageClient.bucket(bucket)
14
+ const googleFile = (0, getClient_1.default)({ projectId })
15
+ .bucket(bucket)
11
16
  .file(key);
12
17
  dataStream.push(data);
13
18
  dataStream.push(null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.3.16",
4
+ "version": "1.3.17",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"