@directus/storage-driver-gcs 11.1.0 → 11.1.1

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/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ type DriverGCSConfig = {
6
6
  bucket: string;
7
7
  apiEndpoint?: string;
8
8
  tus?: {
9
+ enabled: boolean;
9
10
  chunkSize?: number;
10
11
  };
11
12
  };
@@ -14,7 +15,6 @@ declare class DriverGCS implements TusDriver {
14
15
  private bucket;
15
16
  private readonly preferredChunkSize;
16
17
  constructor(config: DriverGCSConfig);
17
- private getPreferredChunkSize;
18
18
  private fullPath;
19
19
  private file;
20
20
  read(filepath: string, options?: ReadOptions): Promise<Readable>;
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/index.ts
2
+ import { DEFAULT_CHUNK_SIZE } from "@directus/constants";
2
3
  import { normalizePath } from "@directus/utils";
3
4
  import { Storage } from "@google-cloud/storage";
4
5
  import { join } from "node:path";
5
6
  import { pipeline } from "node:stream/promises";
6
- var DEFAULT_CHUNK_SIZE = 8388608;
7
7
  var MINIMUM_CHUNK_SIZE = 262144;
8
8
  var DriverGCS = class {
9
9
  root;
@@ -15,16 +15,10 @@ var DriverGCS = class {
15
15
  this.root = root ? normalizePath(root, { removeLeading: true }) : "";
16
16
  const storage = new Storage(storageOptions);
17
17
  this.bucket = storage.bucket(bucket);
18
- this.preferredChunkSize = this.getPreferredChunkSize(tus);
19
- }
20
- getPreferredChunkSize(tus) {
21
- if (!tus?.chunkSize) {
22
- return DEFAULT_CHUNK_SIZE;
23
- }
24
- if (tus.chunkSize < MINIMUM_CHUNK_SIZE || Math.log2(tus.chunkSize) % 1 !== 0) {
18
+ this.preferredChunkSize = tus?.chunkSize || DEFAULT_CHUNK_SIZE;
19
+ if (tus?.enabled && (this.preferredChunkSize < MINIMUM_CHUNK_SIZE || Math.log2(this.preferredChunkSize) % 1 !== 0)) {
25
20
  throw new Error("Invalid chunkSize provided");
26
21
  }
27
- return tus.chunkSize;
28
22
  }
29
23
  fullPath(filepath) {
30
24
  return normalizePath(join(this.root, filepath));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/storage-driver-gcs",
3
- "version": "11.1.0",
3
+ "version": "11.1.1",
4
4
  "description": "GCS file storage abstraction for `@directus/storage`",
5
5
  "homepage": "https://directus.io",
6
6
  "repository": {
@@ -22,8 +22,9 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@google-cloud/storage": "7.13.0",
25
+ "@directus/constants": "12.0.1",
25
26
  "@directus/storage": "11.0.1",
26
- "@directus/utils": "12.0.3"
27
+ "@directus/utils": "12.0.4"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@ngneat/falso": "7.2.0",