Skip to content

Commit

Permalink
Merge branch 'BOTCAHX:pro' into pro
Browse files Browse the repository at this point in the history
  • Loading branch information
official4jelas authored Jan 4, 2025
2 parents cacf595 + 4a20048 commit 51ecfe2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
21 changes: 20 additions & 1 deletion lib/uploadFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ const axios = require('axios')
const FormData = require('form-data');
const { fromBuffer } = require('file-type');


/**
* Upload file to https://i.supa.codes
* @returns {string|null|(string|null)[]}
*/
const supa = async (buffer) => {
let { ext } = await fromBuffer(buffer);
let bodyForm = new FormData();
bodyForm.append("file", buffer, "file." + ext);
let res = await fetch("https://i.supa.codes/api/upload", {
method: "post",
body: bodyForm,
});
let data = await res.json();
let resultUrl = data
return resultUrl.link
}


/**
* Upload file to https://catbox.moe
* @returns {string|null|(string|null)[]}
Expand Down Expand Up @@ -108,7 +127,7 @@ const api = async (buffer) => {

module.exports = async function (inp) {
let err = false;
for (const upload of [quax, catbox, pomf, api, fileIO]) {
for (const upload of [supa, quax, catbox, pomf, api, fileIO]) {
try {
return await upload(inp);
} catch (e) {
Expand Down
50 changes: 22 additions & 28 deletions lib/uploadImage.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
const axios = require('axios');
const FormData = require('form-data');
const { fromBuffer } = require('file-type');
const fetch = require('node-fetch')
const FormData = require('form-data')
const { fromBuffer } = require('file-type')

/**
* Upload image to qu.ax
* Supported mimetype:
* - `image/jpeg`
* - `image/jpg`
* - `image/png`
* @param {Buffer} buffer Image Buffer
*/
* Upload image to url
* Supported mimetype:
* - `image/jpeg`
* - `image/jpg`
* - `image/png`
* - `video/mp4`
* - `all files`
* @param {Buffer} buffer Image Buffer
*/

module.exports = async (buffer) => {
const { ext, mime } = await fromBuffer(buffer);
const form = new FormData();
form.append('files[]', buffer, {
filename: 'tmp.' + ext,
contentType: mime,
let { ext } = await fromBuffer(buffer);
let bodyForm = new FormData();
bodyForm.append("file", buffer, "file." + ext);
let res = await fetch("https://i.supa.codes/api/upload", {
method: "post",
body: bodyForm,
});

const { data } = await axios.post(
"https://qu.ax/upload.php",
form,
{
headers: {
...form.getHeaders(),
}
}
);

return data.files[0].url;
};
let data = await res.json();
let resultUrl = data
return resultUrl.link
}

0 comments on commit 51ecfe2

Please sign in to comment.