deno-linebot icon indicating copy to clipboard operation
deno-linebot copied to clipboard

Buffer data from event.message.content() seems wrong

Open ieiekk opened this issue 2 years ago • 0 comments

I can correctly upload my user's image to ImgBB using line messaging api get content endpoint, but using event.message.content() cannot.

I guess it's this line that get wrong:

// deno-linebot.js
const result = Buffer.from(buffer).toString('hex');

Since this is my own implemented fetch, and it works:

const res = await fetch(
        `https://api-data.line.me/v2/bot/message/${event.message.id}/content`,
        {
          method: "GET",
          headers: {
            "Authorization": `Bearer ${options.channelAccessToken}`,
          },
        },
      );
      const blob = await res.blob();
const buffer = await blob.arrayBuffer();
// import { encode } from "https://deno.land/std/encoding/base64.ts";
const base64 = encode(buffer);

ieiekk avatar Aug 24 '23 04:08 ieiekk