FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

Stop routing 100 GB a day through your app server

Presigned URLs let users upload straight to storage, leaving the application to decide who gets access and a CDN to serve static content.

ShareLinkedInFacebookX

In brief

  • Keep large uploads and downloads out of the app: issue a presigned URL or valet key so the client works with storage directly.
  • Make the token as narrow as possible: one file, one method and a short lifetime, yet long enough for large files and with a way to renew.
  • A token cannot cap data volume or number of uses, so check files after upload; for static content, allow public reads, forbid public writes and put a CDN in front.
Diagram of the presigned URL upload flow. The user requests a URL from the App / API (step 1) and receives a presigned URL in return (step 2), shown as two parallel vertical arrows. In step 3, an orange arrow runs from the user straight to the teal object storage, showing that the file does not pass through the app. In step 4, a review job moves the file's status from pending to ready.
The valet key pattern: the app only decides who may upload and issues a narrow, time-limited URL. Storage handles the data transfer, after which a review job vets the file before it moves to ready. Source: Azure Architecture Center (Microsoft), AWS documentation on presigned URLs.

Two hundred field technicians, each uploading a 500 MB inspection video at the end of the day, produce about 100 GB of traffic. In that hypothetical deployment, if every byte goes through the API, the application server has to take in all 100 GB and push it back out again, every day, to do a job that storage can do by itself.

Microsoft’s Azure Architecture Center describes this cost: an application that proxies uploads and downloads consumes valuable resources such as compute, memory and bandwidth. The valet key pattern hands data transfer to the storage service and leaves the application to decide who may do what.

FDEs meet this requirement again and again. Customers want their users to push documents, images, logs or training data into the system that has just been deployed. The steps below build that flow on a laptop, then put a CDN in front of the static content.

What will you build, and what do you need first?

You will build three things: an endpoint that issues time-limited upload URLs, a flow in which the client uploads straight to storage, and a check that runs on each file after upload. The last part covers storage for static content with a CDN in front.

You need a cloud account with object storage (S3 or Azure Blob), a small backend you are comfortable with, and curl. The server-side snippets below are pseudocode, simplified to show structure rather than any particular SDK’s syntax; for a real build, look up the function that creates presigned URLs in your SDK.

Step 1: how narrow should the key be?

According to AWS documentation, a presigned URL is defined by four things: bucket, object key, HTTP method and expiry time. Whoever holds the URL can upload that object without any AWS credentials or permissions.

Microsoft defines a valet key in the same spirit: a time-limited token that applies only to specific resources and allows only predefined operations, such as writing but not reading. Its sample limits the token to one container and one file, for about 3 minutes, with permission only to create the blob and none to download, update or delete it.

The rule that follows is to be narrow in every dimension: one file, one method, one time window and no surplus permissions.

Step 2: write the endpoint that issues the URL

Microsoft uses a lightweight API running on an Azure Function to issue tokens. A route in your existing backend can do the same:

# Pseudocode, simplified for illustration
POST /uploads            (signed-in user)
  check that the user may upload for this tenant
  object_key = "uploads/{tenant_id}/{new_uuid}"
  url = presign(bucket="customer-uploads",
                key=object_key,
                method="PUT",
                expires_in=<computed in step 4>)
  save object_key to the DB with status "pending"
  return { url, object_key }

The most important detail is that the server generates the object key and never takes it from the filename the user sends. AWS notes that uploading through a presigned URL to a key that already exists overwrites the old object; a client that can choose the key can choose someone else’s file to overwrite.

Check after this step: call the endpoint twice. You should get two different object keys.

Step 3: the client uploads directly, with the app out of the way

The client takes the URL and pushes the file straight to storage:

curl -X PUT --upload-file video.mp4 "$UPLOAD_URL"

To test the scope, send a GET to the same URL with curl "$UPLOAD_URL". The method is part of the URL’s definition, so this request must be refused; if it succeeds, your key is wider than you thought.

AWS calls a presigned URL a bearer token: whoever holds it has the access it grants. Keep full URLs out of application logs, analytics and support tickets.

Step 4: how long should the URL last for large files?

Microsoft recommends a short lifetime to reduce the risk from a leaked token, but warns that if it is too short, large uploads will fail, so a renewal mechanism is needed. The 3 minutes in its sample suits small images. It does not suit every case.

The arithmetic for a 1.8 GB file over a real-world uplink of 10 Mbps: 1.8 × 1024 × 8 = 14,745.6 megabits, divided by 10 gives about 1,475 seconds, or nearly 25 minutes. A 3-minute token is certain to fail. A sensible approach is to calculate from the customer’s largest file and slowest connection, then add a safety margin.

As for the upper limit, AWS allows 1 minute to 12 hours in the console, and up to 7 days through the CLI or SDK. There is a trap: a URL signed with temporary credentials, such as an IAM role session, expires with those credentials even if you set a longer lifetime.

Large downloads have a trap of their own. According to AWS, S3 checks expiry when the request arrives: a download in progress continues after the URL expires, but if the connection drops and the client resumes after that point, the request fails. The client should therefore know how to ask your endpoint for a new URL instead of endlessly retrying an old one.

For that reason, add a renewal route alongside the one in step 2. It does not generate a new key. It re-signs the existing key, and only for the user who already owns it:

# Pseudocode, simplified for illustration
POST /uploads/{object_key}/renew   (signed-in user)
  look up object_key in the DB
  reject if it does not belong to this user
  reject if status is not "pending"
  url = presign(bucket="customer-uploads",
                key=object_key,
                method="PUT",
                expires_in=<as in step 4>)
  return { url }

Downloads work the same way: the client calls your endpoint again for a new GET URL to the same object, after the server checks read permission. Check after this step: let a URL expire and confirm that PUT fails; call the renew route and confirm that PUT succeeds with the new URL, and that the object key in the database has not changed.

Step 5: why check files after upload?

Many people skip this part. Microsoft is explicit that it is usually not possible to create a key that limits how much data is written, or one that limits how many times it is used. A legitimate user can still upload a huge file, a file in the wrong format or a malicious one.

Hence the post-upload check. When a file reaches storage, a job reads the object key in “pending” status, checks size and format, scans for malicious content and only then moves it to “ready”. The renew route in step 4 relies on the same status: once a file is “ready”, no more write URLs are issued for it.

Microsoft also advises monitoring costs to spot abnormal growth in volume. On Azure, the create permission makes a token close to single-use, which helps contain the damage if it leaks.

Common errors and fixes

Symptom Common cause Fix
SignatureDoesNotMatch Clock drift on the machine signing the URL Sync with an NTP server; even a small drift can break the signature
SignatureDoesNotMatch despite a correct clock A proxy in between modifies headers or the query string Send requests straight to storage, not through a proxy that rewrites URLs
Large upload fails partway through Lifetime too short for the file size Calculate from the largest file and use the renew route in step 4
URL expires earlier than set Signed with temporary credentials Check the session duration of the role signing the URL

If the customer needs assurance that files are not corrupted in transit, AWS supports upload integrity checks using checksums in SigV4.

Step 6: does static content need a key?

Not every file needs a valet key. Microsoft’s Static Content Hosting pattern places images, scripts and stylesheets directly on storage and adds a CDN in front for better performance, at additional cost. The container must allow public reads but never public writes; content that needs protection goes back to valet keys.

A CDN, according to Wikipedia, is a geographically distributed network of proxy servers and data centers that brings content closer to users. The system-design-primer distinguishes two kinds: a pull CDN fetches content from the origin server when the first user requests it, so that first request is slower; a push CDN suits content that is rarely accessed or seldom updated.

The costs of a CDN, also according to system-design-primer, are money, content that may be stale if you update it before the TTL runs out, and the need to change URLs for static content. A practical answer is to put a version in the filename, such as app.v42.js: each deployment gets a new URL, so no old copy sits waiting for its TTL to expire.

Step 7: watch a CDN serve a stale copy, then fix it

This simplified exercise uses a pull CDN pointed at the static container you have just created. First check permissions: try to write a file straight to the container without a token. That request must be refused, as with the GET test in step 3.

# $CDN is the CDN domain pointing at the static container (simplified)
curl "$CDN/app.js"   # 1st call: the CDN has to fetch the file from the origin
curl "$CDN/app.js"   # 2nd call: should come from cache, faster

Now edit app.js, upload it to storage under the same name and request it through the CDN again. If the TTL has not expired, you will most likely still get the old version: the stale content system-design-primer warns about.

Finally, upload the new version as app.v2.js and request that URL. You will get the new content at once, because the CDN has never seen this file; the first request may be slower, as the description of pull CDNs suggests. You pass when you can explain all three results.

What does this skill look like at a customer site?

On site, the first question is usually who is proxying the files, before any debate over S3 versus Blob. Open the application server’s logs and bandwidth charts: if upload traffic accounts for most of the load, you have a concrete, measurable proposal.

When reading FDE job descriptions, look for mentions of taking in files or data from customers, in phrases such as “file ingestion” or “data onboarding”. Where they appear, this exercise is one to talk through in the interview.

On a resume, “used S3” says too little. Write that you moved uploads to presigned URLs, chose token lifetimes based on real file sizes, built a renewal route and added a post-upload content check.

The first thing to do in your first week with a customer: find the heaviest upload endpoint, measure how many bytes pass through the app each day, and bring that number, with the presigned URL design above, to the next technical meeting.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
5 sources
Read next on the roadmap · Stage 5: DeploymentCaching a slow client system can trade slowness for wrong dataThree Redis strategies in the order you will need them: cache-aside by default, write-through for freshness, refresh-ahead for hot keys.