How to Get a Public URL for Any File: 4 Methods Compared

March 31, 2026 · 6 min read

You have a file, an image, a PDF, a CSV, a video, and you need a URL that anyone can access. Maybe you are embedding an image in an email, sharing a document with a client, serving assets from a web app, or feeding a file to a webhook. Whatever the reason, you need to go from "file on my machine" to "publicly accessible URL" as fast as possible.

This guide covers four practical methods to do that, from zero-code drag-and-drop to fully automated API calls. Each method has different trade-offs around speed, automation, and permanence.

Why You Need a Public File URL

Public file URLs are the connective tissue of the modern web. Here are the most common reasons developers and non-developers alike need them:

The key requirement in all these cases is the same: a stable, fast, publicly accessible URL that does not expire.

Method 1: Drag and Drop (No Signup Required)

FilePost has a try-upload feature on its homepage that lets you drag and drop a file and get a public URL instantly, without creating an account. This is the fastest way to get a one-off URL.

How it works

  1. Go to filepost.dev
  2. Drag your file onto the upload area (or click to select a file)
  3. The file uploads and you get a CDN URL immediately

The URL looks like this:

https://cdn.filepost.dev/file/filepost/uploads/a1/a1b2c3.png

Best for: One-off uploads when you need a URL right now and do not need to manage the file later. No signup, no API key, no code.

Limitations: Manual process. Not suitable if you need to upload files programmatically or in bulk.

Method 2: Upload via REST API (cURL One-Liner)

If you are comfortable with the terminal, a single cURL command gets you from file to URL in seconds. This is the sweet spot between manual uploads and full code integration.

curl -X POST https://filepost.dev/v1/upload \
  -H "X-API-Key: your_api_key_here" \
  -F "file=@report.pdf"

Response:

{
  "url": "https://cdn.filepost.dev/file/filepost/uploads/a1/a1b2c3.pdf",
  "file_id": "a1b2c3d4e5f6",
  "size": 84210
}

Copy the url value and you are done. The file is live on a CDN, accessible to anyone with the link.

You can make this even faster with a shell alias:

# Add to your ~/.bashrc or ~/.zshrc
alias upload='curl -s -X POST https://filepost.dev/v1/upload \
  -H "X-API-Key: your_api_key_here" \
  -F "file=@$1" | jq -r .url'

# Usage
upload photo.png

Best for: Developers who want a quick upload from the terminal. Great for scripting and CI/CD pipelines.

Method 3: Upload with Python

For Python applications or automation scripts, the requests library handles everything cleanly:

import requests

def get_public_url(file_path, api_key):
    """Upload a file and return its public CDN URL."""
    with open(file_path, "rb") as f:
        response = requests.post(
            "https://filepost.dev/v1/upload",
            headers={"X-API-Key": api_key},
            files={"file": f}
        )
    response.raise_for_status()
    return response.json()["url"]

# Example usage
url = get_public_url("screenshot.png", "your_api_key_here")
print(url)
# https://cdn.filepost.dev/file/filepost/uploads/a1/a1b2c3.png

This is a building block you can drop into any Python project. Use it in a Django view to handle user uploads, in a data pipeline to store generated reports, or in a bot to host images before posting them to Slack.

Batch Upload

Need to upload an entire directory? Wrap it in a loop:

import os
import requests

api_key = "your_api_key_here"
upload_dir = "./exports"

for filename in os.listdir(upload_dir):
    filepath = os.path.join(upload_dir, filename)
    if os.path.isfile(filepath):
        with open(filepath, "rb") as f:
            resp = requests.post(
                "https://filepost.dev/v1/upload",
                headers={"X-API-Key": api_key},
                files={"file": f}
            )
        data = resp.json()
        print(f"{filename} -> {data['url']}")

Best for: Integrating file uploads into Python apps, automation scripts, data pipelines, and backend services.

Get a Public URL for Any File in One API Call

300 free uploads per month. 2GB storage. Files live forever. No credit card required. Paid plans get unlimited storage.

Get Your Free API Key

Method 4: Upload with Node.js

Node.js 18+ includes built-in fetch and FormData, so you do not need any npm packages:

import { readFile } from "fs/promises";
import { basename } from "path";

async function getPublicUrl(filePath, apiKey) {
  const buffer = await readFile(filePath);
  const file = new File([buffer], basename(filePath));

  const form = new FormData();
  form.append("file", file);

  const response = await fetch("https://filepost.dev/v1/upload", {
    method: "POST",
    headers: { "X-API-Key": apiKey },
    body: form,
  });

  const data = await response.json();
  return data.url;
}

// Example usage
const url = await getPublicUrl("./invoice.pdf", "your_api_key_here");
console.log(url);
// https://cdn.filepost.dev/file/filepost/uploads/a1/a1b2c3.pdf

Best for: Node.js applications, serverless functions, Express/Fastify backends, and frontend build scripts that need to upload assets.

Permanent URLs vs Temporary Links

Not all file hosting services treat URLs the same way. This is an important distinction that can bite you if you do not pay attention to it upfront.

Temporary links expire after a set period, anywhere from a few hours to 30 days. Services like AWS S3 presigned URLs are temporary by default. If you embed a temporary URL in an email or store it in a database, it will eventually stop working.

Permanent links live as long as the file exists. The URL does not change and does not expire. This is what you want for most use cases: images in emails, assets in production apps, documents shared with clients, and media stored in a CMS.

FilePost URLs are permanent. Once you upload a file, the CDN URL works forever, there is no expiration, no renewal, and no additional cost for keeping files hosted. You only pay based on the number of uploads per month, not storage or bandwidth.

If you do need to remove a file, you can delete it via the API:

curl -X DELETE https://filepost.dev/v1/files/a1b2c3d4e5f6 \
  -H "X-API-Key: your_api_key_here"

Which Method Should You Choose?

Method Speed Automation Best For
Drag and drop Instant None One-off uploads, non-developers
cURL Fast Scriptable Terminal users, CI/CD, quick tests
Python Fast Full Backend apps, data pipelines, bots
Node.js Fast Full Web apps, serverless, build scripts

If you just need a URL right now and do not care about automation, use the drag-and-drop method on filepost.dev. If you are building an application or automating a workflow, the API is the way to go, pick whichever language you are already using.

All four methods give you the same result: a permanent, CDN-delivered public URL that works anywhere on the web.