DEV Community

momo_dev2
momo_dev2

Posted on

How to Upload Files and Get Public URLs with One API Call

If you've ever needed to upload a file and get a public URL for a webhook, automation workflow, or just sharing. You know the pain of setting up S3 buckets, IAM policies, and CDN distributions.

I built FilePost to make this a one liner.

Upload a file

curl -X POST https://filepost.dev/v1/upload \
  -H "X-API-Key: fh_your_key" \
  -F "file=@photo.png"
Enter fullscreen mode Exit fullscreen mode

Get a CDN URL

{
  "url": "https://cdn.filepost.dev/file/filepost/uploads/a1/a1b2c3.png",
  "file_id": "a1b2c3d4e5f6",
  "size": 84210
}
Enter fullscreen mode Exit fullscreen mode

That's it. The URL is permanent and served via Cloudflare CDN.

It also works with Python and Node.js

Python:

import requests

r = requests.post(
    "https://filepost.dev/v1/upload",
    headers={"X-API-Key": "fh_your_key"},
    files={"file": open("photo.png", "rb")}
)
print(r.json()["url"])
Enter fullscreen mode Exit fullscreen mode

Node.js:

const form = new FormData();
form.append('file', fs.createReadStream('photo.png'));

const res = await fetch('https://filepost.dev/v1/upload', {
  method: 'POST',
  headers: { 'X-API-Key': 'fh_your_key' },
  body: form
});
console.log((await res.json()).url);
Enter fullscreen mode Exit fullscreen mode

Full file management

Not just upload, you can list, get metadata, and delete files too:

  • GET /v1/files — list your files
  • GET /v1/files/{id} — get details
  • DELETE /v1/files/{id} — remove a file

Free tier

30 uploads/month, 50MB max file size. No credit card needed. Get an API key at filepost.dev.


I'd love to hear how you handle file uploads in your projects. Do you roll your own S3 setup or use a service?

Top comments (0)