There will be the following garbled characters
銇撱倱銇仭銇�,浣犲ソ,Hello
Access https://test-r2.cfm.moe/1685369836787.txt to view.
this is demo
Is this issue caused by my storage method?
export default {
async fetch(request, env, ctx) {
const { pathname } = new URL(request.url);
if (pathname === "/test") {
const content = "こんにちは,你好,Hello";
const id = Date.now();
const arrayBuffer = new TextEncoder().encode(
JSON.stringify(content)
).buffer;
console.log(new TextDecoder().decode(new Uint8Array(arrayBuffer)));
await env.R2.put(`${id}.txt`, arrayBuffer);
return new Response(JSON.stringify({
code: 200,
content,
url: `https://test-r2.cfm.moe/${id}.txt`,
}));
}
return new Response(null, { status: 404 });
},
};