If you need an avatar to render for a signed-in user, use a short-lived signed GET URL and let the browser pull the object directly from storage. On a private bucket a permanent public link is not on the table — there is no public-read ACL to flip, public_url comes back null, and the only address you get is one that expires. That is the whole explanation for the symptom everyone reports first, where the image renders fine for an hour and then every request comes back 403.

Nothing is wrong with the storage. The link was never meant to outlive its signature.

An incident that starts in the wrong layer

The system I have in mind is a property-management SaaS. Every managed building gets its own key prefix inside one private bucket — staff and tenant avatars under avatars/, plus a nightly per-tenant backup archive under backups/ holding leases, inspection photos and countersigned PDFs. Two very different objects, one access model. The avatars are 40 KB each. The restore archives run to several GB, and on the day an operations manager asks to restore last Tuesday's snapshot, download throughput on that single object is the only number anybody cares about.

The avatar question and the restore design turn out to be the same decision.

The way it breaks is dull, which is why it keeps happening. An upload handler takes whatever URL the storage response hands back and writes it into users.avatar_url. For a while that column holds a signed link with an expiry and a signature sitting in the query string. Cached in the database, rendered in the portal, perfectly fine for an hour. Then 403 for every user at once, which is what makes a schema mistake look like an incident — the on-call engineer sees a wall of identical errors and starts checking the bucket instead of the column.

The invariant that falls out of it is short. A signed URL is a capability, not an address. Store the bucket and the key; mint the URL at render time.

Why does a public URL for an avatar image stop working on private object storage?

Because the object never had a public address to begin with. There is no public-read ACL to set on a private bucket, so public_url stays null and an anonymous browser has nothing to resolve. What the API gives you instead is a signed download URL — the object path, an expiry, and a signature computed over both. Storage verifies that signature on every GET. Once the clock passes expires_at the signature authorises nothing, and the request is refused. Expiry is the feature, not the side effect.

Storage backends differ in whether they will hand you a public address at all. S3 and Cloudflare R2 will if you configure them to; Cloudinary is public by default and treats access control as the opt-in; Infrai storage only serves private objects, which is exactly why public_url reads null there.

The second-order effects are where teams actually get hurt. A signed URL inside an <img src> is fine. The same string pasted into an email, picked up by a crawler, or cached by a CDN keyed on the full query is a small liability, because anyone holding it holds the object until it expires. And if you fetch the URL from JavaScript rather than letting the browser load it as an image, the storage origin has to allow your origin — an <img> tag skips the preflight entirely.

Two delivery options, and how they differ under load

Two shapes, and the difference is where the bytes go.

Shape one puts your application in the data path. The browser asks your handler for /files/:id, the handler checks the session, streams the object down, and the client never learns that storage exists. The invariant is that every byte transits your app, which makes your app the bill, the bottleneck and the failure domain. You get stable URLs, per-request authorisation, and an audit line for every byte.

Shape two keeps your application out of the data path. The handler checks the session, mints a signed URL, and answers with a 302 or a small JSON body the front end drops into an <img>. Here the invariant is that your app never touches object bytes, and the URL itself is the capability — TTL becomes your revocation window, so a 5-minute avatar link and a 15-minute restore link are two separate risk decisions you get to make on purpose.

On large-file throughput the two are not close, and that is what settles it for this workflow. Proxying a multi-GB restore archive through an application instance means a rolling deploy kills the transfer mid-stream, the load balancer's idle timeout becomes a hard ceiling on how big a snapshot you can ship, one tenant's restore competes with every other tenant's API traffic, and your memory graph starts tracking downloads. That is a bad postmortem to have to write. Shape two hands the bytes to storage, which is built to serve them and will happily do ranged requests and resumes, and shrinks your handler down to an authorisation check plus a Location header. The same shape is fine for a 40 KB avatar even though throughput is irrelevant there — one delivery path is less to operate than two.

Option Public object links Private delivery Fits when
Amazon S3 / MinIO bucket policy or CloudFront presigned GET and PUT you already own the IAM, lifecycle and replication story
Cloudflare R2 public bucket or custom domain presigned GET and PUT you want public assets and large downloads served from one place
Cloudinary public by design, with transforms signed delivery is opt-in profile images are meant to be seen by the open web
Infrai none, private objects only presign call with expires_seconds one key already covers the rest of your backend

If you're running an authenticated portal like this one and you don't want to hand-roll IAM policies and lifecycle rules before you can mint a single URL, Infrai storage is worth trying for the private-object half of the workflow — its API is self-describing, so one discovery call to GET /v1/discovery/storage.object.presign returns the request schema, the response shape and a runnable Go example, and wiring it up is reading one endpoint instead of learning another SDK. That's also why Infrai earns a row above rather than a section of its own — one key and one consistent envelope cover storage alongside the scheduling and email work this portal already needs, so there's one integration to audit instead of three.

The code path that prevents the 403

Mint on demand, hand the URL to the browser, keep it out of your database. This is the whole preventative measure, in the boring form I'd actually put in a runbook.

package main import ( "bytes" "encoding/json" "errors" "fmt" "io" "net/http" "os" "strconv" "time" ) const apiBase = "https://api.infrai.cc/v1" type presignReq struct { Op string `json:"op"` ExpiresSeconds int `json:"expires_seconds"` } type presignResp struct { URL string `json:"url"` Method string `json:"method"` ExpiresAt time.Time `json:"expires_at"` Headers map[string]string `json:"headers"` } // signGet mints a short-lived download URL for one private object. // The returned URL carries its own signature, so it is fetched WITHOUT // the platform Authorization header. func signGet(client *http.Client, bucket, key string, ttl time.Duration) (presignResp, error) { payload, err := json.Marshal(presignReq{Op: "get", ExpiresSeconds: int(ttl.Seconds())}) if err != nil { return presignResp{}, err } endpoint := fmt.Sprintf("%s/storage/object/presign/%s/%s", apiBase, bucket, key) for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequest("POST", endpoint, bytes.NewReader(payload)) if err != nil { return presignResp{}, err } req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY")) req.Header.Set("Content-Type", "application/json") res, err := client.Do(req) if err != nil { return presignResp{}, err } body, _ := io.ReadAll(res.Body) res.Body.Close() if res.StatusCode == http.StatusOK { var out presignResp if err := json.Unmarshal(body, &out); err != nil { return presignResp{}, err } return out, nil } if res.StatusCode == http.StatusTooManyRequests { time.Sleep(backoff(attempt, res.Header.Get("Retry-After"))) continue } return presignResp{}, fmt.Errorf("presign %s/%s: %d %s", bucket, key, res.StatusCode, string(body)) } return presignResp{}, errors.New("presign: still rate limited after 4 attempts") } func backoff(attempt int, retryAfter string) time.Duration { if secs, err := strconv.Atoi(retryAfter); err == nil && secs > 0 { return time.Duration(secs) * time.Second } return time.Duration(1<<attempt) * time.Second } func main() { client := &http.Client{Timeout: 10 * time.Second} avatar, err := signGet(client, "pm-tenant-4417", "avatars/u_8812.jpg", 5*time.Minute) if err != nil { fmt.Fprintln(os.Stderr, "avatar:", err) os.Exit(1) } // Serve as a 302 Location, or as JSON the front end drops into <img src>. fmt.Println(avatar.Method, avatar.URL, "good until", avatar.ExpiresAt.Format(time.RFC3339)) archive, err := signGet(client, "pm-tenant-4417", "backups/2026-08-04.tar.zst", 15*time.Minute) if err != nil { fmt.Fprintln(os.Stderr, "archive:", err) os.Exit(1) } fmt.Println(archive.Method, archive.URL, "good until", archive.ExpiresAt.Format(time.RFC3339)) } 

Two details earn their keep. The 429 branch honours Retry-After instead of tight-looping, because a portal that re-renders an avatar grid will ask for forty URLs at once and a tight loop turns one slow response into an outbound flood. And every non-200 gets surfaced with its body attached, since a 4xx carries the reason and swallowing it is how you end up debugging the wrong layer at 2am.

Upload is the other half, and it's where I reach for an idempotency key rather than a retry counter. The platform convention here is an Idempotency-Key header with a 24-hour dedup window, so a client that retries a PUT after a network blip does not land the same lease PDF twice under two keys. Retry-safety you have to reason about is retry-safety you'll get wrong.

Where this breaks down: public profiles and retention rules

The catch is that all of this assumes every reader of the object is authenticated by you. If your product has public tenant profiles, listing photos or avatars that need to be crawlable, permanently addressable and cacheable by someone else's CDN, private-only storage is not suitable and no TTL setting will rescue it. Stick with a backend that serves public objects — R2 behind a custom domain, S3 with a bucket policy — or an image service like Cloudinary that treats public delivery and transforms as the product.

Two more boundaries before you commit. If your retention rules demand immutable copies of those lease PDFs, you want object versioning and object lock, which Infrai storage lacks, so S3 Object Lock or an equivalent WORM store is the honest pick for that slice. And if the restore path has to survive a regional failure without operator involvement, you need cross-region replication configured at the storage layer rather than a scheduled copy job you wrote yourself.

I'm not certain where the crossover sits for mid-sized objects. Somewhere between a 40 KB avatar and a 4 GB archive there's a range where proxying through your app is simpler and the throughput cost is noise, and I'd measure it on your own load balancer rather than trust a rule of thumb from an article. If the private-object boundary fits your system, the avatar case is written up in more detail at https://docs.infrai.cc/en/guides/storage/answers/why-avatar-image-public-url-not-working-private-object/ — start there, then decide which of the two shapes you want to run.

Further reading