Last active
February 10, 2025 03:14
-
-
Save Noktomezo/342c1ebba10c57b75d4b33946bb162c5 to your computer and use it in GitHub Desktop.
Upload to Ranoz.gg
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
import fs from "node:fs"; | |
import path from "node:path"; | |
async function uploadFile(fileAbsolutePath: string) { | |
const filePath = path.resolve(fileAbsolutePath); | |
const fileName = path.basename(filePath); | |
try { | |
// Step 1: Obtain a Pre-Signed URL | |
const { size } = fs.statSync(filePath); | |
const response = await fetch("https://ranoz.gg/api/v1/files/upload_url", { | |
method: "POST", | |
headers: { "Content-Type": "application/json" }, | |
body: JSON.stringify({ filename: fileName, size }), | |
}); | |
if (response.ok) { | |
const { | |
data: { url, upload_url }, | |
} = await response.json(); | |
// Step 2: Upload the File to the Pre-Signed URL | |
const fileBuffer = fs.readFileSync(filePath); | |
const uploadResponse = await fetch(upload_url, { | |
method: "PUT", | |
headers: { "Content-Length": size.toString() }, | |
body: fileBuffer, | |
}); | |
if (uploadResponse.ok) { | |
console.log("File uploaded successfully:", url); | |
} else { | |
console.error("Upload failed:", await uploadResponse.text()); | |
} | |
} else { | |
console.error("Failed to get upload URL:", await response.text()); | |
} | |
} catch (error) { | |
console.error("Error:", error); | |
} | |
} | |
await uploadFile(Deno.args[0]); | |
// "Пауза" для предотвращения мгновенного закрытия консоли (аналог pause) | |
console.log("\nНажмите Enter для выхода..."); | |
const buf = new Uint8Array(1024); | |
await Deno.stdin.read(buf); |
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
1) Convert SVG to ICO: https://convertio.co/ru/svg-ico/ | |
2) Compile: deno compile --allow-net --allow-read --icon .\ranoz.ico -o upload-to-ranoz upload-to-ranoz.ts | |
3) Move "upload-to-ranoz.exe" to: C:\Program Files\ | |
4) Run: "add-update-to-ranoz-to-context-menu.reg" | |
5) Click on any file with right click + shift |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment