@michaelthielemann/kestrel-blobstore-s3 5.0.3 → 5.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/README.md CHANGED
@@ -4,8 +4,9 @@ via `@aws-sdk/client-s3`. Config: `bucket`, optional `prefix` (`"site/"`), `regi
4
4
  `forcePathStyle`, `accessKeyId`/`secretAccessKey` (omit to use the SDK's default credential chain:
5
5
  environment, profile, instance role), `timeoutMs` (default 10000, used for both the connection and
6
6
  the request timeout, so a silent socket never hangs a pipeline step) and `maxAttempts` (default 3,
7
- the SDK's retry limit including the first try). `list()` reports `application/octet-stream` as
8
- content type because S3 listings carry no metadata; `get()` returns the stored type.
7
+ the SDK's retry limit including the first try). `put` stores the `contentType` hint as the object's
8
+ `Content-Type`, so a bucket served directly answers with the right type; `get` returns bytes only
9
+ and `list` reports key and size. The store never wrote sidecar files.
9
10
 
10
11
  `pnpm test:s3` runs the `blobstore@1` contract test against a real MinIO instance in Podman
11
12
  (starts it, creates the bucket, runs `minio.test.ts`, always stops the container).
package/dist/impl.js CHANGED
@@ -50,9 +50,9 @@ export function createBlobstoreS3(config, client = createClient(config)) {
50
50
  if (client instanceof S3Client)
51
51
  client.destroy();
52
52
  },
53
- async put(key, blob) {
53
+ async put(key, data, options = {}) {
54
54
  try {
55
- await client.send(new PutObjectCommand({ Bucket: config.bucket, Key: fullKey(key), Body: blob.data, ContentType: blob.contentType }));
55
+ await client.send(new PutObjectCommand({ Bucket: config.bucket, Key: fullKey(key), Body: data, ...(options.contentType === undefined ? {} : { ContentType: options.contentType }) }));
56
56
  return ok();
57
57
  }
58
58
  catch (cause) {
@@ -66,7 +66,7 @@ export function createBlobstoreS3(config, client = createClient(config)) {
66
66
  const out = (await client.send(new GetObjectCommand({ Bucket: config.bucket, Key: fullKey(key) })));
67
67
  if (!out.Body)
68
68
  return ok(null);
69
- return ok({ data: await out.Body.transformToByteArray(), contentType: out.ContentType ?? "application/octet-stream" });
69
+ return ok(await out.Body.transformToByteArray());
70
70
  }
71
71
  catch (cause) {
72
72
  if (cause instanceof NoSuchKey || cause.name === "NoSuchKey")
@@ -121,7 +121,7 @@ export function createBlobstoreS3(config, client = createClient(config)) {
121
121
  for (const item of page.Contents ?? []) {
122
122
  if (item.Key === undefined)
123
123
  continue;
124
- out.push({ key: item.Key.slice(config.prefix.length), size: item.Size ?? 0, contentType: "application/octet-stream" });
124
+ out.push({ key: item.Key.slice(config.prefix.length), size: item.Size ?? 0 });
125
125
  }
126
126
  token = page.NextContinuationToken;
127
127
  } while (token);