Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: kv:key put no longer able to upload binary files #1254

Closed
f5io opened this issue Jun 14, 2022 · 3 comments · Fixed by #1255 or #1287
Closed

🐛 BUG: kv:key put no longer able to upload binary files #1254

f5io opened this issue Jun 14, 2022 · 3 comments · Fixed by #1255 or #1287
Assignees
Labels
bug Something that isn't working

Comments

@f5io
Copy link
Contributor

f5io commented Jun 14, 2022

What version of Wrangler are you using?

2.0.8

What operating system are you using?

Mac

Describe the Bug

We've just upgraded from wrangler 1 -> 2. We were using wrangler kv:key put to upload images into KV from CLI. It seems in wrangler 2 those images get mangled when uploading.

I believe it is related to this line and the fact that values are always passed as strings...
https://github.com/cloudflare/wrangler2/blob/e3ce82b0cbb5e5765fa09ab3322b42a5b75934e3/packages/wrangler/src/index.tsx#L2262-L2265

@f5io f5io added the bug Something that isn't working label Jun 14, 2022
@petebacondarwin
Copy link
Contributor

Thanks for reporting this issue. I'll take a look. I suspect that we need a way to determine that the file contains binary data and therefore needs to be base64 encoded...

@f5io
Copy link
Contributor Author

f5io commented Jun 14, 2022

Hi @petebacondarwin, it can actually be fixed by not using the readFileSync utility from here and instead directly leveraging node:fs readFileSync without an encoding, to get a Buffer back.

have just tested this and it works, happy to PR if needs be

@petebacondarwin
Copy link
Contributor

Thanks @f5io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
2 participants