Created
August 19, 2024 14:18
-
-
Save tai2/50397bf26bd3c949191211e0aea7a464 to your computer and use it in GitHub Desktop.
Upload file to giga便
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uuid = require("uuid"); | |
const crypto = require("crypto"); | |
const fs = require("fs"); | |
const buffer = require('buffer'); | |
const upload = async () => { | |
const id = crypto.randomBytes(16).toString("hex"); | |
console.log('id', id) | |
const blob = new Blob(['hello there']); | |
const formData = new FormData() | |
formData.append('id', id); | |
formData.append('name', 'test.txt'); | |
formData.append('chunk', 0); | |
formData.append('chunks', 1); | |
formData.append('lifetime', 60); | |
formData.append('file', blob, 'blob'); | |
//formData.append('file', fs.readFileSync("./test.txt"), 'blob'); | |
const response = await fetch("https://46.gigafile.nu/upload_chunk.php", { | |
method: 'POST', | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0', | |
}, | |
body: formData | |
}); | |
console.log(response.headers) | |
console.log(response.status) | |
const responseBody = await response.text(); | |
console.log(responseBody) | |
} | |
upload(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment