Skip to content

Instantly share code, notes, and snippets.

@Noktomezo
Last active February 10, 2025 03:14
Show Gist options
  • Save Noktomezo/342c1ebba10c57b75d4b33946bb162c5 to your computer and use it in GitHub Desktop.
Save Noktomezo/342c1ebba10c57b75d4b33946bb162c5 to your computer and use it in GitHub Desktop.
Upload to Ranoz.gg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Upload to Ranoz.gg]
@="Upload to Ranoz.gg"
"Extended"=""
"Icon"="C:\\Program Files\\upload-to-ranoz.exe"
[HKEY_CLASSES_ROOT\*\shell\Upload to Ranoz.gg\command]
@="\"C:\\Program Files\\upload-to-ranoz.exe\" \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\Upload to Ranoz.gg]
@="Upload to Ranoz.gg"
"Extended"=""
"Icon"="C:\\Program Files\\upload-to-ranoz.exe"
[HKEY_CLASSES_ROOT\Directory\shell\Upload to Ranoz.gg\command]
@="\"C:\\Program Files\\upload-to-ranoz.exe\" \"%1\""
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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);
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