diff --git a/.changeset/eleven-tigers-double.md b/.changeset/eleven-tigers-double.md new file mode 100644 index 0000000..30aa4ca --- /dev/null +++ b/.changeset/eleven-tigers-double.md @@ -0,0 +1,5 @@ +--- +"middy-store-s3": patch +--- + +fix: use startsWith instead of equals to check content type diff --git a/packages/store-s3/src/store.ts b/packages/store-s3/src/store.ts index 8296588..a73cd82 100644 --- a/packages/store-s3/src/store.ts +++ b/packages/store-s3/src/store.ts @@ -203,14 +203,15 @@ export class S3Store implements StoreInterface { ): Promise { const { Body, ContentType } = result; - if (ContentType === "text/plain") { + // TODO check for charset encoding + if (ContentType?.startsWith("text/plain")) { const payload = await Body?.transformToString("utf-8"); if (payload === undefined) throw new Error("Payload is undefined"); return payload as unknown; } - if (ContentType === "application/json") { + if (ContentType?.startsWith("application/json")) { const payload = await Body?.transformToString("utf-8"); if (payload === undefined) throw new Error("Payload is undefined");