Skip to content

L-mn #3

@yongo-faith

Description

@yongo-faith

const fetch = require('node-fetch')
const FormData = require('form-data')
const { fromBuffer } = require('file-type')

/**

  • Upload image to telegra.ph
  • Supported mimetype:
    • image/jpeg
    • image/jpg
    • image/png
  • @param {Buffer} buffer Image Buffer
    */
    module.exports = async buffer => {
    let { ext } = await fromBuffer(buffer);
    let bodyForm = new FormData();
    bodyForm.append("fileToUpload", buffer, "file." + ext);
    bodyForm.append("reqtype", "fileupload");

let res = await fetch("https://catbox.moe/user/api.php", {
method: "POST",
body: bodyForm,
});

let data = await res.text();
return data;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions