esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Valet Key: Give Clients a Short-Lived Pass to Reach Storage Directly

Learn how an app can let a phone upload or download one file straight from cloud storage, without sending every byte through its own servers.

In short

A valet key is a short-lived pass an app gives a client so it can upload or download one file directly from cloud storage, without sending every byte through the app's servers.

10 min readFree

What You Will Learn

Imagine a photo app where every upload travels through the app's own servers before it reaches storage. That works for a few users. As more people upload, it becomes slow and expensive. The Valet Key pattern offers another path. The app checks who the user is, then hands the phone a short-lived pass that opens one storage location directly. By the end of this lesson you will be able to explain the problem the pattern solves, walk through its steps, and name the trade-offs you must accept.

Key words

Valet key
A short-lived pass that lets a client use one specific resource directly.
Token
A piece of data that proves a client has permission to do something. The storage service checks it on each request.
Signed URL
A web address that already contains its permissions and a signature, so the storage service can check it without asking your app.
Proxy
A middleman server that receives data and forwards it on to somewhere else.
Scope
The exact set of things a token can reach, such as one file or one folder.
Expiry
The time after which a token or URL stops working.
Object storage
A service that keeps files, such as photos, as named objects inside containers called buckets.
Bandwidth
How much data a network connection can carry over a period of time.
Revoke
To cancel access before its expiry time.

What Is the Problem with Data Flowing Through Your Servers?

Phones and web browsers often need to send files to an app, or fetch files from it. The simplest design has the app receive each file and then forward it to storage. For downloads, the app fetches the file from storage and sends it back to the user. In both cases the app acts as a proxy. Every byte passes through your machines, even though your app never needs to read the bytes.

This is the core problem. Your app is doing the slow, costly work of moving data it does not need to understand. The pattern's source describes this as a cost the application absorbs in compute, memory, and bandwidth. The next part shows what that looks like in practice.

Why Does Proxying Hurt?

  • Bandwidth costs

    Every upload and download uses your network twice: once between the client and your app, and again between your app and storage. You pay for both legs.

  • Compute and memory

    Your servers must hold open a connection for each transfer and use memory and processor time to move the data along. Large files make this worse.

  • A single bottleneck

    When many users upload at once, all of that traffic squeezes through your app. Slow transfers tie up app capacity that should serve other requests, and the app can become the slowest part of the system.

Tip

Ask yourself which part of your app actually needs to read the file. If the answer is none of it, the file probably should not pass through the app at all.

What Is the Valet Key Idea?

The Valet Key pattern splits the work into two jobs. Your app does the decision. Storage does the transfer. The app checks identity and permissions, and then it issues a pass. The pass lets the client reach exactly one resource, for exactly the actions it needs, for a short time. After that, the client talks to storage directly. Your app stays out of the data path.

The pass can take two forms. A token is data the client sends with its request, which the storage service checks. A signed URL is a web address that already carries its permissions and a signature. Either way, the storage service can decide on its own whether the request is allowed.

How Does the Pattern Work?

  1. 1

    The client asks for access

    The phone or browser tells your app what it wants to do, such as upload one photo or download one receipt. It sends its normal login so your app knows who is asking.

  2. 2

    The app checks identity and permissions

    Your app confirms the user is logged in and is allowed to touch that resource. This is the only step where your app's own rules apply. If the check fails, no pass is issued.

  3. 3

    The app issues a scoped pass

    The app creates a token or signed URL. The pass names one resource, lists one set of actions such as read or write, and sets a short expiry time.

  4. 4

    The client talks straight to storage

    The client sends the file to, or fetches it from, the storage service using the pass. The bytes never touch your app. When the pass expires, it stops working, and a new one must be requested.

Notice that the app is involved twice at most: once to issue the pass and, if needed, once to record the result. The heavy transfer happens between the client and storage.

Scope and Expiry: The Two Limits That Matter Most

A valet key is only safe if it is narrow. Scope means the pass reaches one resource, such as one file path, and not the whole bucket. It also means one kind of action. A pass to upload a photo should not let the holder read other photos or delete anything. Expiry means the pass stops working after a short time. A short expiry limits the damage if the pass is copied or leaked.

Good design sets both limits every time a pass is issued. Do not reuse one long-lived pass for many actions, because a wide pass is almost as risky as the master access it was meant to replace.

Worked Example: Uploading a Photo

Take a photo-sharing app. Its storage is Amazon S3, a bucket of objects. A user taps Upload to add a picture to their album. Here is what happens, step by step, using a pre-signed URL. In S3, a pre-signed URL is a link that the storage service accepts for a set time, without needing the client to hold the storage account's keys.

  1. 1

    The phone asks to upload

    The app sends a request to its backend that says, in effect, I want to upload one photo to my album. The request carries the user's login.

  2. 2

    The backend checks the user

    The backend confirms the login is valid and that this user may write to their own album path. It picks one file path for the new photo, such as a path inside that user's album.

  3. 3

    The backend returns a pre-signed URL

    The backend creates a pre-signed S3 URL for that one object path, allowing an upload, and sets it to expire after 5 minutes. It sends the URL back to the phone.

  4. 4

    The phone uploads straight to S3

    The phone sends the photo to the URL. The photo goes directly to S3 and never passes through the app's servers. Once the upload finishes, the phone tells the backend it is done, so the backend can record the photo and check it.

The backend did a small, fast job: one check and one signed link. The large transfer ran on storage, which is built to handle it.

Quick check

A team is building a receipt download feature. A user asks for a PDF receipt, and the team wants the phone to fetch it straight from storage. Which design follows the Valet Key pattern safely?

Security and Trade-Offs

The pattern moves work away from your app, but it also moves trust. Once a pass is in a client's hands, your app no longer sits between the client and the data. You must design for that. The source material for this pattern and the security guidance from cloud providers point to a short list of habits.

  • Keep passes narrow and short-lived

    Scope each pass to one resource and one set of actions. Use the shortest expiry that still lets a normal user finish the task.

  • Remember that a pass is a bearer item

    Anyone holding the token or URL can use it until it expires. A leaked link works for a stranger just as well as for the user. Expiry is an important limit, so keep it short.

  • Allow revocation where you can

    Some systems let you cancel a pass early. Where that is not possible, rely on short expiry and narrow scope instead.

  • Use HTTPS

    Send passes only over encrypted connections. A pass sent in plain text can be read by anyone on the network path.

  • Check uploaded data afterward

    A valid pass proves the client may upload. It does not prove the file is safe or the right type. Validate the file's type and size, and scan it, after the upload finishes.

Quick check

A user's signed upload URL is pasted into a public chat by mistake. The URL has not expired yet. What is the main risk, and what limit reduced it?

Quick check

A backend issued a signed upload URL, and the file has now arrived in storage. What should the backend do before trusting the file?

When Should You Use the Pattern?

The pattern fits best when large files move between clients and storage, and when your app only needs to decide who may access them. Photos, videos, documents, and exported reports are common cases. It fits less well when your app must read or change each byte in transit, such as transforming a file as it arrives. In that case, the app may still need to be in the data path, or you may need a separate processing step after the upload.

Tip

When you design a feature, write down three things for each pass: the resource, the actions, and the expiry. If you cannot fill in all three, the pass is not narrow enough yet.

Key Takeaways

Valet Key moves the heavy transfer from your app to storage. Your app keeps the decision: it checks identity, scopes a pass to one resource and one set of actions, and sets a short expiry. The client then talks to storage directly. The gains are lower bandwidth cost, less load on your servers, and fewer bottlenecks. The costs are that a pass can be used by anyone who holds it, and that uploaded data must still be checked. Keep passes narrow, keep them short-lived, send them only over HTTPS, and validate what arrives.

Sources

How is this lesson?

Last updated on 18 November 2026

Learn with me

Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.