How to Get a File URL (Public Link) for Any File
To get a file URL, upload the file to a service that returns a public HTTPS address. A browser upload is enough for a one-off share; an API is better when your app or automation needs a repeatable upload and a URL it can store.
The four methods below cover a one-off share, a browser workflow, a command-line script, and a fully automated API path. Choose based on how long the link must live and whether the upload will happen once or repeatedly.
How do I get a file URL?
Upload the file with a browser, cURL, Python, or another HTTP client, then copy the url value returned by the upload service. For a single share, use drag and drop. For repeatable workflows, use an automation integration or the upload API.
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:
- Embedding images in HTML emails, Email clients do not support file attachments inline. You need a hosted URL for every image in your email template.
- Sharing files in Slack, Discord, or Teams, Drop a URL and the platform renders a preview. Much cleaner than uploading the file directly.
- Populating CMS content, Headless CMS platforms store media as URLs. You need hosted files to populate image fields and document links.
- Webhook payloads, Many APIs expect you to pass a URL to a file rather than the file itself. Payment processors, form builders, and notification services all work this way.
- App assets and user uploads, Your application needs to serve user-uploaded files from a reliable CDN, not from your own server.
The key requirement in all these cases is the same: a stable, fast, publicly accessible URL with no automatic expiry by default.
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, enter an email, and get a working public URL without a separate signup form. Verify the email within 24 hours to keep the URL permanently.
How it works
- Go to filepost.dev
- Drag your file onto the upload area (or click to select a file)
- 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://upload.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.
For format-specific API examples, see the image to URL guide, PDF to URL guide, or remote file to URL guide.
You can make this even faster with a shell alias:
# Add to your ~/.bashrc or ~/.zshrc
alias upload='curl -s -X POST https://upload.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://upload.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://upload.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
One provisional 10 MB upload works before verification. Verify your email within 24 hours to keep it permanently and unlock 15 uploads/month, 50 MB files, and 2 GB storage. No credit card required.
Get Your Free API KeyMethod 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://upload.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.
Questions About File URLs and Public Links
How do I get a URL of a file?
Upload the file and use the returned url field. With the FilePost API, a successful upload returns a JSON object containing the CDN URL, file ID, filename, size, and content type. Store the URL if another system needs to display or download the file later.
How do I create a public link for a file?
Use a file host that serves uploaded files over HTTPS, then share the returned URL. A public link is different from a local path such as /Users/me/report.pdf: anyone with the HTTPS link can request the hosted file, subject to the service's access and retention rules.
How do I get an image URL from a file?
Upload the image as a file, preserve its image filename and content type, and use the returned URL in an img element, CMS field, email, or automation payload. For an application, the API method avoids copying URLs manually.
How long does a file link last?
That depends on the hosting service. Temporary links expire after a set period; durable public URLs keep working until the file is deleted, expires by policy, or the account is closed. Check the retention rule before storing a URL in a database or production content.
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 are stable URLs for durable public access. The URL does not change and has no automatic expiry by default. 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 designed for durable public access. Once you upload a file, the CDN URL has no automatic expiry by default and keeps working until you delete the file, configure expiry, or the account is terminated. 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 CDN-delivered public URL that works anywhere on the web.