I got a buffer not a body!

This commit is contained in:
Sam Poder 2023-02-25 09:50:40 +08:00
parent d05d80da7f
commit 0dde879c7a
4 changed files with 4 additions and 4 deletions

View file

@ -79,7 +79,7 @@ export default async (req: Request) => {
}
const decoder = new TextDecoder();
const buf = await Deno.readAll(req.body);
const buf = await request.arrayBuffer();
const fileURLs = JSON.parse(decoder.decode(buf));
if (!Array.isArray(fileURLs) || fileURLs.length < 1) {
return new Response(

View file

@ -48,7 +48,7 @@ export default async (req: Request) => {
}
const decoder = new TextDecoder();
const buf = await Deno.readAll(req.body);
const buf = await request.arrayBuffer();
const singleFileURL = decoder.decode(buf);
if (typeof singleFileURL != "string") {
return new Response(

View file

@ -6,7 +6,7 @@ import { ensurePost, parseBody } from "./utils.ts";
export default async (req: Request) => {
if (!ensurePost(req)) return null;
const body = await parseBody(req.body);
const body = await request.arrayBuffer();
const fileURLs = JSON.parse(body);
if (!Array.isArray(fileURLs) || fileURLs.length < 1) {

View file

@ -46,7 +46,7 @@ const upload = async (url: string, authorization: string | null) => {
export default async (req: Request) => {
if (!ensurePost(req)) return null;
const body = await parseBody(req.body);
const body =await request.arrayBuffer();
const uploadedFileUrl = await upload(body, req.headers.get("Authorization"));
return new Response(JSON.stringify(uploadedFileUrl));