@vankyle/storage-s3 0.3.1 → 0.4.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/README.md
CHANGED
|
@@ -81,6 +81,12 @@ const storage = new S3Storage({
|
|
|
81
81
|
|
|
82
82
|
All four URL types use `@aws-sdk/s3-request-presigner`.
|
|
83
83
|
|
|
84
|
+
`createReadUrl` and `DefaultStorageService.getReadUrl` support optional
|
|
85
|
+
`responseContentDisposition` and `responseContentType` overrides. They are
|
|
86
|
+
passed to S3 as `response-content-disposition` and `response-content-type`
|
|
87
|
+
query parameters on the presigned URL, so S3 sets those response headers on the
|
|
88
|
+
eventual GET.
|
|
89
|
+
|
|
84
90
|
## Options reference
|
|
85
91
|
|
|
86
92
|
```typescript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-storage.test.d.ts","sourceRoot":"","sources":["../../src/storage/s3-storage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { S3Storage } from "../storage/s3-storage.js";
|
|
3
|
+
function createStorage() {
|
|
4
|
+
return new S3Storage({
|
|
5
|
+
clientConfig: {
|
|
6
|
+
region: "us-east-1",
|
|
7
|
+
endpoint: "https://s3.example.test",
|
|
8
|
+
credentials: {
|
|
9
|
+
accessKeyId: "test-access-key",
|
|
10
|
+
secretAccessKey: "test-secret-key",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
forcePathStyle: true,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
describe("S3Storage", () => {
|
|
17
|
+
describe("createReadUrl", () => {
|
|
18
|
+
it("should include response header overrides in the presigned URL", async () => {
|
|
19
|
+
const storage = createStorage();
|
|
20
|
+
const signed = await storage.createReadUrl({
|
|
21
|
+
bucket: "test-bucket",
|
|
22
|
+
objectKey: "path/to/demo.txt",
|
|
23
|
+
expiresInSeconds: 600,
|
|
24
|
+
responseContentDisposition: "attachment; filename=\"demo.txt\"; filename*=UTF-8''demo.txt",
|
|
25
|
+
responseContentType: "text/plain",
|
|
26
|
+
});
|
|
27
|
+
const params = new URL(signed.url).searchParams;
|
|
28
|
+
expect(params.get("response-content-disposition")).toBe("attachment; filename=\"demo.txt\"; filename*=UTF-8''demo.txt");
|
|
29
|
+
expect(params.get("response-content-type")).toBe("text/plain");
|
|
30
|
+
});
|
|
31
|
+
it("should omit response header override query params when not provided", async () => {
|
|
32
|
+
const storage = createStorage();
|
|
33
|
+
const signed = await storage.createReadUrl({
|
|
34
|
+
bucket: "test-bucket",
|
|
35
|
+
objectKey: "path/to/demo.txt",
|
|
36
|
+
expiresInSeconds: 600,
|
|
37
|
+
});
|
|
38
|
+
const params = new URL(signed.url).searchParams;
|
|
39
|
+
expect(params.has("response-content-disposition")).toBe(false);
|
|
40
|
+
expect(params.has("response-content-type")).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=s3-storage.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-storage.test.js","sourceRoot":"","sources":["../../src/storage/s3-storage.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,SAAS,aAAa;IACpB,OAAO,IAAI,SAAS,CAAC;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,yBAAyB;YACnC,WAAW,EAAE;gBACX,WAAW,EAAE,iBAAiB;gBAC9B,eAAe,EAAE,iBAAiB;aACnC;SACF;QACD,cAAc,EAAE,IAAI;KACrB,CAAC,CAAC;AACL,CAAC;AAED,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,QAAQ,CAAC,eAAe,EAAE,GAAG,E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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vankyle/storage-s3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "S3-compatible object storage adapter for vankyle-storage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"homepage": "https://github.com/Vankyle-Hub/storage-ts",
|
|
32
32
|
"packageManager": "pnpm@10.28.2",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@vankyle/storage-core": "0.
|
|
35
|
-
"@vankyle/storage-shared": "0.
|
|
34
|
+
"@vankyle/storage-core": "0.4.0",
|
|
35
|
+
"@vankyle/storage-shared": "0.4.0",
|
|
36
36
|
"@aws-sdk/client-s3": "^3.1029.0",
|
|
37
37
|
"@aws-sdk/s3-request-presigner": "^3.1029.0"
|
|
38
38
|
},
|