@rytass/storages-adapter-gcs 0.1.1 → 0.1.3

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/index.cjs.js CHANGED
@@ -16,7 +16,7 @@ class StorageGCSService extends storages.Storage {
16
16
  });
17
17
  this.bucket = this.storage.bucket(options.bucket);
18
18
  }
19
- async url(key, expires = 1000 * 60 * 60 * 24) {
19
+ async url(key, expires = Date.now() + 1000 * 60 * 60 * 24) {
20
20
  const file = this.bucket.file(key);
21
21
  const [url] = await file.getSignedUrl({
22
22
  action: 'read',
@@ -105,6 +105,11 @@ class StorageGCSService extends storages.Storage {
105
105
  async remove(key) {
106
106
  await this.bucket.file(key).delete();
107
107
  }
108
+ async isExists(filename) {
109
+ const file = this.bucket.file(filename);
110
+ const [exists] = await file.exists();
111
+ return exists;
112
+ }
108
113
  }
109
114
 
110
115
  exports.StorageGCSService = StorageGCSService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/storages-adapter-gcs",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Google Cloud Storage Adapter for @rytass/storages",
5
5
  "keywords": [
6
6
  "gcp",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@google-cloud/storage": "^6.5.3",
25
- "@rytass/storages": "^0.1.2",
25
+ "@rytass/storages": "^0.1.3",
26
26
  "uuid": "^8.3.2"
27
27
  },
28
28
  "devDependencies": {
@@ -16,4 +16,5 @@ export declare class StorageGCSService extends Storage<GCSOptions> {
16
16
  write(file: InputFile, options?: WriteFileOptions): Promise<StorageFile>;
17
17
  batchWrite(files: InputFile[]): Promise<StorageFile[]>;
18
18
  remove(key: string): Promise<void>;
19
+ isExists(filename: string): Promise<boolean>;
19
20
  }
@@ -12,7 +12,7 @@ class StorageGCSService extends Storage {
12
12
  });
13
13
  this.bucket = this.storage.bucket(options.bucket);
14
14
  }
15
- async url(key, expires = 1000 * 60 * 60 * 24) {
15
+ async url(key, expires = Date.now() + 1000 * 60 * 60 * 24) {
16
16
  const file = this.bucket.file(key);
17
17
  const [url] = await file.getSignedUrl({
18
18
  action: 'read',
@@ -101,6 +101,11 @@ class StorageGCSService extends Storage {
101
101
  async remove(key) {
102
102
  await this.bucket.file(key).delete();
103
103
  }
104
+ async isExists(filename) {
105
+ const file = this.bucket.file(filename);
106
+ const [exists] = await file.exists();
107
+ return exists;
108
+ }
104
109
  }
105
110
 
106
111
  export { StorageGCSService };