@basaltkit/storage-gcs 1.0.1 → 1.1.0
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 +3 -2
- package/dist/index.js +8 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PutOptions, type StorageDriver } from '@basaltkit/storage';
|
|
1
|
+
import { type TemporaryUrlOptions, type PutOptions, type StorageDriver } from '@basaltkit/storage';
|
|
2
2
|
/** The subset of a `@google-cloud/storage` File this driver uses. */
|
|
3
3
|
export interface GcsFileLike {
|
|
4
4
|
save(data: Buffer, options?: {
|
|
@@ -10,6 +10,7 @@ export interface GcsFileLike {
|
|
|
10
10
|
getSignedUrl(config: {
|
|
11
11
|
action: 'read';
|
|
12
12
|
expires: number;
|
|
13
|
+
responseDisposition?: string;
|
|
13
14
|
}): Promise<[string]>;
|
|
14
15
|
}
|
|
15
16
|
/** The subset of a `@google-cloud/storage` Bucket this driver uses. */
|
|
@@ -43,7 +44,7 @@ export declare class GcsStorageDriver implements StorageDriver {
|
|
|
43
44
|
exists(path: string): Promise<boolean>;
|
|
44
45
|
delete(path: string): Promise<boolean>;
|
|
45
46
|
list(prefix: string): Promise<string[]>;
|
|
46
|
-
temporaryUrl(path: string, expiresInMs: number): Promise<string>;
|
|
47
|
+
temporaryUrl(path: string, expiresInMs: number, options?: TemporaryUrlOptions): Promise<string>;
|
|
47
48
|
disconnect(): Promise<void>;
|
|
48
49
|
private bucket;
|
|
49
50
|
}
|
package/dist/index.js
CHANGED
|
@@ -43,10 +43,14 @@ export class GcsStorageDriver {
|
|
|
43
43
|
const [files] = await (await this.bucket()).getFiles({ prefix });
|
|
44
44
|
return files.map((file) => file.name);
|
|
45
45
|
}
|
|
46
|
-
async temporaryUrl(path, expiresInMs) {
|
|
47
|
-
const [url] = await (await this.bucket())
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
async temporaryUrl(path, expiresInMs, options) {
|
|
47
|
+
const [url] = await (await this.bucket()).file(path).getSignedUrl({
|
|
48
|
+
action: 'read',
|
|
49
|
+
expires: Date.now() + expiresInMs,
|
|
50
|
+
// Signed response header: uploaded HTML/SVG downloads instead of
|
|
51
|
+
// rendering on the storage origin ('attachment' is the Disk default).
|
|
52
|
+
responseDisposition: options?.disposition ?? 'attachment',
|
|
53
|
+
});
|
|
50
54
|
return url;
|
|
51
55
|
}
|
|
52
56
|
async disconnect() { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basaltkit/storage-gcs",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Google Cloud Storage driver for @basaltkit/storage — put/get/list/delete/signed URLs over @google-cloud/storage, with an injectable client for testing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@basaltkit/storage": "^1.
|
|
17
|
+
"@basaltkit/storage": "^1.3.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@google-cloud/storage": "^7.0.0"
|