-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
In order to return binary data (eg. a generated Image) from a Netlify function, the data must be converted to a base64 encoded string with the proper content-type.
This is done in handler.js, but the condition that checks for Uint8Array will always fail, as the response type changed with #3384
From what I can tell, there is currently no way to determine the "type" from the response, other than looking at the content-type header and using something like is_text
Reproduction
Here's a minimal setup: https://github.com/bummzack/sveltekit-netlify-binary-response
There's twice the same code running in a SvelteKit Endpoint (image.png) and a separate Netlify function.
The SvelteKit endpoint does not encode the image properly and it won't be displayed:
https://elated-knuth-7439db.netlify.app/image.png
The direct implementation as a separate Netlify function works as expected:
https://elated-knuth-7439db.netlify.app/.netlify/functions/test
Logs
No response
System Info
Local system is irrelevant, since the issue doesn't occur locally.
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.30
@sveltejs/kit: next => 1.0.0-next.288
svelte: ^3.44.0 => 3.46.4Severity
annoyance
Additional Information
No response