upload2picbed

uploading image to the picbed

Usage no npm install needed!

<script type="module">
  import upload2picbed from 'https://cdn.skypack.dev/upload2picbed';
</script>

README

upload2picbed

to upload image to the picbed

how to install

npm i upload2picbed

how to use

//to use it on your server
const fs = require('fs');
const upload = require('upload2picbed');

async function catbox() {
    let uploadResult = await upload(
        'https://catbox.moe/user/api.php', {
            'fileToUpload': fs.createReadStream('./1.png'),
            'reqtype': 'fileupload',
            'userhash': '',
        }, {
            'accept': 'application/json',
            'referer': 'https://catbox.moe/'
        }
    );
    //response struct: https://files.catbox.moe/xxxxx.png
    //the url is https://files.catbox.moe/xxxxx.png
    console.log(uploadResult.data)
}

catbox() 
//To get result data, no use async, await
const upload = require('upload2picbed');
let uploadResult = await upload(
        'https://catbox.moe/user/api.php', {
            'fileToUpload': fs.createReadStream('./1.png'),
            'reqtype': 'fileupload',
            'userhash': '',
        }, {
            'accept': 'application/json',
            'referer': 'https://catbox.moe/'
        }
);

uploadResult.then(data => {
  //show the data
  console.log(data.data);
})