@vankyle/storage-s3 0.3.0 → 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 +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/mappers/index.d.ts +1 -1
- package/dist/mappers/index.js +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/s3-storage.d.ts +1 -1
- package/dist/storage/s3-storage.js +1 -1
- package/dist/storage/s3-storage.test.d.ts +2 -0
- package/dist/storage/s3-storage.test.d.ts.map +1 -0
- package/dist/storage/s3-storage.test.js +44 -0
- package/dist/storage/s3-storage.test.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -3
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
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { S3Storage } from "./storage/index";
|
|
2
|
-
export type { S3StorageOptions } from "./types/index";
|
|
1
|
+
export { S3Storage } from "./storage/index.js";
|
|
2
|
+
export type { S3StorageOptions } from "./types/index.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { S3Storage } from "./storage/index";
|
|
1
|
+
export { S3Storage } from "./storage/index.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/mappers/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mapS3HeadToCore } from "../mappers/s3-head-to-core";
|
|
1
|
+
export { mapS3HeadToCore } from "../mappers/s3-head-to-core.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mappers/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mapS3HeadToCore } from "../mappers/s3-head-to-core";
|
|
1
|
+
export { mapS3HeadToCore } from "../mappers/s3-head-to-core.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { S3Storage } from "../storage/s3-storage";
|
|
1
|
+
export { S3Storage } from "../storage/s3-storage.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/storage/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { S3Storage } from "../storage/s3-storage";
|
|
1
|
+
export { S3Storage } from "../storage/s3-storage.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IStorage, type StorageCapabilities, type PutObjectInput, type PutObjectResult, type GetObjectInput, type GetObjectResult, type HeadObjectInput, type HeadObjectResult, type DeleteObjectInput, type InitUploadSessionInput, type InitUploadSessionResult, type UploadPartInput, type UploadPartResult, type CompleteUploadSessionInput, type CompleteUploadSessionResult, type AbortUploadSessionInput, type CreateReadUrlInput, type CreatePutUrlInput, type CreateUploadPartUrlInput, type SignedAccess } from "@vankyle/storage-core";
|
|
2
|
-
import type { S3StorageOptions } from "../types/s3-options";
|
|
2
|
+
import type { S3StorageOptions } from "../types/s3-options.js";
|
|
3
3
|
export declare class S3Storage implements IStorage {
|
|
4
4
|
readonly provider: "s3";
|
|
5
5
|
readonly capabilities: StorageCapabilities;
|
|
@@ -2,7 +2,7 @@ import { S3Client, PutObjectCommand, GetObjectCommand, HeadObjectCommand, Delete
|
|
|
2
2
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
3
3
|
import { StorageProvider, } from "@vankyle/storage-core";
|
|
4
4
|
import { StorageError, StorageObjectNotFoundError, } from "@vankyle/storage-shared";
|
|
5
|
-
import { mapS3HeadToCore } from "../mappers/s3-head-to-core";
|
|
5
|
+
import { mapS3HeadToCore } from "../mappers/s3-head-to-core.js";
|
|
6
6
|
const DEFAULT_EXPIRES_IN = 3600; // 1 hour
|
|
7
7
|
export class S3Storage {
|
|
8
8
|
provider = StorageProvider.S3;
|
|
@@ -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,EAAE;QAC7B,EAAE,CAAC,+DAA+D,EAAE,KAAK,IAAI,EAAE;YAC7E,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;YAEhC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC;gBACzC,MAAM,EAAE,aAAa;gBACrB,SAAS,EAAE,kBAAkB;gBAC7B,gBAAgB,EAAE,GAAG;gBACrB,0BAA0B,EACxB,8DAA8D;gBAChE,mBAAmB,EAAE,YAAY;aAClC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC;YAChD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC,IAAI,CACrD,8DAA8D,CAC/D,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qEAAqE,EAAE,KAAK,IAAI,EAAE;YACnF,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;YAEhC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC;gBACzC,MAAM,EAAE,aAAa;gBACrB,SAAS,EAAE,kBAAkB;gBAC7B,gBAAgB,EAAE,GAAG;aACtB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC;YAChD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/D,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { S3StorageOptions } from "../types/s3-options";
|
|
1
|
+
export type { S3StorageOptions } from "../types/s3-options.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/package.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
|
},
|