I'm struggling with a binary response in an HttpAPI.
My endpoint is this
const CreateSetEndpoint = HttpApiEndpoint.post("createSet", "/create-set").addSuccess(
Schema.Uint8ArrayFromSelf.pipe(
HttpApiSchema.withEncoding({
kind: "Uint8Array",
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
})
)
);
// implementation is type-safe, so omited for brevity
export const handler = LambdaHandler.fromHttpApi(
Layer.mergeAll(HeraklesApiLive, HttpServer.layerContext)
);
I can compile and deploy it as a HttpApi. Calls to the endpoint return a file, but the file is corrupted. I checked the business logic which works fine, so the problem must happen somewhere on the API side.
I checked the tests and there is no test for binary responses at the moment. When checking the code I was wondering whether the logic here is correct https://github.com/floydspace/effect-aws/blob/92a98b16f412edb4a74708fe19e5aa8daf96dd11/packages/lambda/src/LambdaHandler.ts#L291C1-L293C49
If so, then the check here
|
export const isContentTypeBinary = (contentType: string) => { |
should return true for "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" which is the mime type of an excel file. But it returns false, which I guess is the root issue here.
I'm struggling with a binary response in an HttpAPI.
My endpoint is this
I can compile and deploy it as a HttpApi. Calls to the endpoint return a file, but the file is corrupted. I checked the business logic which works fine, so the problem must happen somewhere on the API side.
I checked the tests and there is no test for binary responses at the moment. When checking the code I was wondering whether the logic here is correct https://github.com/floydspace/effect-aws/blob/92a98b16f412edb4a74708fe19e5aa8daf96dd11/packages/lambda/src/LambdaHandler.ts#L291C1-L293C49
If so, then the check here
effect-aws/packages/lambda/src/internal/utils.ts
Line 107 in 92a98b1