Uploader JavaScript SDK
Upload files and shorten URLs from Node and TypeScript with the hepgg package, using native multipart with no extra dependencies.
Uploader SDK
The hepgg package wraps the Uploader in a typed client. Hand it a Buffer, Blob, or Uint8Array and it builds the multipart request for you with native FormData. It also shortens URLs through the same endpoint.
Install
Upload A File
import { Uploader } from "hepgg/uploader";
import { readFile } from "node:fs/promises";
const up = new Uploader({ token: process.env.HYD_UP_KEY });
const png = await readFile("cat.png");
const { url } = await up.upload(png, { filename: "cat.png", contentType: "image/png" });
console.log(url); // https://i.hep.gg/abc123.pngupload() accepts a Buffer, Uint8Array, Blob, File, or ArrayBuffer. The filename drives the stored extension.
Shorten A URL
Send a link to the same endpoint and get a short URL back.
const { url } = await up.shorten("https://example.com/very/long/path");
console.log(url); // https://i.hep.gg/aB3dEOptions And Errors
new Uploader(options)
tokenstringrequired
Your
hyd-up- token.baseURLstringoptionaldefault:
https://hep.ggUpload host.
serveHoststringoptionaldefault:
https://i.hep.ggUsed by
urlFor(id) to build a serve URL.authSchemeraw | beareroptionaldefault:
rawHow the token is sent. The upload route expects the raw header; switch to
bearer only if your account requires it.timeoutMsnumberoptionaldefault:
10000Per-request timeout.
retriesnumberoptionaldefault:
2Safe retries. An upload is never replayed after a server response.
import { HepError } from "hepgg";
try {
await up.upload(buf, { filename: "big.zip" });
} catch (err) {
if (err instanceof HepError && err.status === 403) console.error("too large or access not enabled");
}