[ CLICK TO BROWSE PHOTO, VIDEO, OR MUSIC ]
METHOD: POST
https://upload.ravagee.tech/api/upload
{
"status": true,
"message": "File uploaded successfully!",
"data": {
"filename": "example.jpg",
"folder": "images",
"url": "https://upload.ravagee.tech/upload/main/images/example.jpg",
"size": 12345,
"mimetype": "image/jpeg",
"type": "images"
}
}
{
"status": false,
"message": "Invalid file format or size too large"
}
const multer = require("multer");
const axios = require("axios");
const upload = multer({
storage: multer.memoryStorage()
});
module.exports = function (app) {
app.options("/api/upload", (req, res) => {
res.sendStatus(200);
});
app.post("/api/upload", upload.single("file"), async (req, res) => {
try {
if (!req.file) {
return res.status(400).json({
status: false,
error: "File tidak ditemukan"
});
}
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
if (!GITHUB_TOKEN) {
return res.status(500).json({
status: false,
error: "GITHUB_TOKEN tidak ditemukan."
});
}
let folder = "files";
if (req.file.mimetype.startsWith("image/")) {
folder = "images";
} else if (req.file.mimetype.startsWith("audio/")) {
folder = "music";
} else if (req.file.mimetype.startsWith("video/")) {
folder = "videos";
}
const filename = `${Date.now()}-${req.file.originalname}`;
const filepath = `${folder}/${filename}`;
await axios.put(
`https://api.github.com/repos/DaffaDevv/upload/contents/${filepath}`,
{
message: `Upload ${filename}`,
content: req.file.buffer.toString("base64")
},
{
headers: {
Authorization: `Bearer ${GITHUB_TOKEN}`,
Accept: "application/vnd.github+json"
}
}
);
return res.json({
status: true,
message: "File uploaded successfully!",
data: {
filename: filename,
folder: folder,
url: `https://upload.ravagee.tech/upload/main/${filepath}`,
size: req.file.size,
mimetype: req.file.mimetype,
type: folder
}
});
} catch (err) {
console.log(err.response?.data || err.message);
return res.status(500).json({
status: false,
error: err.response?.data || err.message
});
}
});
};
import requests
URL = "https://upload.ravagee.tech/api/upload"
payload = {'file': open('photo.jpg', 'rb')}
try:
response = requests.post(URL, files=payload)
print(response.json())
except Exception as e:
print(f"Failed: {e}")
Layanan hosting gambar berperforma tinggi dengan infrastruktur yang cepat dan aman. Dirancang untuk pengembang yang membutuhkan solusi penyimpanan aset yang handal dan mudah diintegrasikan.