Loading snippets...
file uploader support berbagai macam file
/**
* FileDitch Uploader
* Author: ShanMolvyr
* sumber: https://whatsapp.com/channel/0029VbB4Kw8EFeXfeExaXc3Q
* base: https://new.fileditch.com
* Usage: node fileditch.js foto.png
*/
const fs = require('fs');
const path = require('path');
const BASE_URL = 'https://new.fileditch.com/upload.php';
async function getDirectUrl(viewUrl) {
const res = await fetch(viewUrl, { headers: { 'User-Agent': 'Mozilla/5.0' } });
const html = await res.text();
const match = html.match(/src="(https:\/\/thegumonmyshoe\.me\/[^"]+)"/);
if (!match) throw new Error('Direct URL tidak ditemukan');
const url = match[1].replace(/&/g, '&');
const expiresMatch = url.match(/expires=(\d+)/);
const expiresAt = expiresMatch ? new Date(parseInt(expiresMatch[1]) * 1000).toISOString() : null;
return { url, expiresAt };
}
async function uploadToFileDitch(fileBuffer, filename) {
const uploadRes = await fetch(`${BASE_URL}?filename=${encodeURIComponent(filename)}`, {
method: 'POST',
headers: { 'Content-Type': 'application/octet-stream' },
body: fileBuffer,
});
if (!uploadRes.ok) throw new Error(`HTTP ${uploadRes.status}`);
const json = await uploadRes.json();
if (!json.success) throw new Error(json.error || 'Upload failed');
const direct = await getDirectUrl(json.url);
return {
success: true,
filename: json.filename,
size: json.size,
url: json.url,
direct_url: direct.url,
direct_expires_at: direct.expiresAt,
};
}
// --- pemakaian langsung ---
const filePath = process.argv[2];
if (!filePath) {
console.error(JSON.stringify({ success: false, error: 'Usage: node fileditch.js <path/to/file>' }));
process.exit(1);
}
const fileBuffer = fs.readFileSync(filePath);
const filename = path.basename(filePath);
uploadToFileDitch(fileBuffer, filename)
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ success: false, error: err.message }));
process.exit(1);
});