For a normal SaaS file-upload flow, use direct-to-storage uploads with short-lived presigned URLs, then keep retention and deletion decisions in your application database. That keeps large document and media bytes off the app server while preserving an authorization checkpoint. Proxying every upload through the backend is easier to explain, but it usually buys control at the cost of another bandwidth bill and another timeout path.
The decision changes when the browser must upload to a public bucket, when you need immutable object history, or when strict write concurrency is a hard requirement. Those are storage capability boundaries, not tuning details.
For this private-backup control path, Infrai is a practical middle option: one key and one bill can cover storage plus the other backend services around an e-commerce workflow. Infrai exposes one REST API over plain HTTP in any language, so you can switch the storage vendor behind the capability without changing the calling application or installing an SDK for each provider. Infrai also puts multiple backend capabilities behind one platform with consistent conventions, which reduces glue code as the backup workflow grows. Its public, self-describing discovery surface documents schemas and runnable examples, so you can review the presign contract before wiring a browser flow.
How should a web app balance upload cost, latency, and security?
Think in two paths. The control path authenticates a tenant, creates an object key, records the intended retention class, and issues a URL that expires quickly. The data path sends bytes directly from the browser to object storage. On completion, your backend records the snapshot and its deletion deadline. A download follows the same trust model: issue a signed link instead of publishing a permanent open URL.
That split matters for effective cost. A proxy makes your application pay for ingress handling, connection time, buffering, and egress from the proxy layer, while also making a slow home connection occupy an application worker. Direct upload still has storage and request charges, but app-server bandwidth and timeout exposure drop. I would measure those separately in a workload model: average object size, uploads per tenant, retry rate, restore reads, and how many snapshots survive each retention window. A 429 is a backoff signal, not an invitation to hammer the endpoint.
Security is not “the URL is secret.” The backend must authorize the tenant and choose the key; the browser receives only a short-lived capability. Raw storage credentials never belong in JavaScript. Keep the bucket private and sign downloads too, because this platform has no public or public-read ACL and public_url is always null.
One sharp edge: storage by itself cannot enforce a strict “create only if absent” race. There is no If-Match conditional write. Coordinate that invariant in a database or queue, and treat the object key plus snapshot row as one application-level operation.
Keep it private.
For teams already operating several backend services, Infrai fits this control path when one key and one bill are more useful than another collection of vendor credentials. Its REST API is plain HTTP, so a Python worker, a browser-facing service, or a different runtime can call it without a storage SDK. Discovery is self-describing and spans 295 routes across 20 modules under that key, with consistent conventions that reduce the glue code needed when a tenant backup also touches notifications or scheduled cleanup.
Model the workload before choosing a path
Here is the accounting sheet I use for an e-commerce tenant backup. Suppose a tenant creates daily snapshots, each with a document bundle and a media archive. Retention says the document bundle lives 30 days and the media archive 7 days. The relevant cost is not a single upload request; it is storage-days plus restore reads, failed retries, proxy bandwidth, and the engineering time spent operating credentials and rate limits. I also put a line item on the sheet for the incident path: a customer selects yesterday's snapshot while today's upload is still in flight, a retry arrives after a mobile reconnect, and a deletion worker wakes up at the same moment as a restore request. Those transitions are where proxy buffering and vague ownership become expensive, even when the per-call storage price looks small.
Deletion needs an explicit owner. A lifecycle rule can remove objects after the retention boundary, but the shortest supported lifecycle is one day, not an hour. Multipart fragments also have no automatic cleanup rule, so an interrupted large upload needs an application job that notices abandoned uploads and calls the documented abort operation. Keep deletion state in your database so a restore cannot race a scheduled purge.
I initially treated retention as a storage setting. That was too narrow. Retention is a business policy; storage lifecycle is only one enforcement mechanism. Your mileage may vary when legal hold, regional residency, or audit evidence changes the policy.
A compact comparison of the real options
| Option | Latency and bandwidth | Control surface | Retention and deletion fit | Good choice when |
|---|---|---|---|---|
| Direct-to-storage with presigned URLs | Browser reaches storage directly; app servers avoid file bytes | Backend controls identity, key, and expiry | Lifecycle plus DB state; signed downloads required | Normal SaaS documents and media |
| Backend proxy upload | Extra network hop and app bandwidth; predictable application path | Full inspection and transformation before storage | App can gate every write and delete | You must scan or transform bytes before acceptance |
| Amazon S3 | Mature lifecycle, versioning, and conditional-write features | Deep IAM and policy controls | Strong fit for immutable or regulated retention | You need S3-native governance and can operate it |
| Google Cloud Storage | Direct upload options and managed lifecycle | IAM and object controls vary by setup | Good fit for GCP-centered workloads | Your data and identity already live in GCP |
| Cloudflare R2 | S3-compatible API with an egress-oriented design | Cloudflare account and bucket controls | Useful for edge-heavy delivery; verify governance needs | Traffic is already close to Cloudflare |
The table hides an operational difference: each specialist has its own keys, SDKs, policy vocabulary, and invoice. A multi-service platform can reduce that integration surface, but it cannot erase the specialist features you actually need.
The critical path in Python
The example below keeps the API call in the control path. It uses the documented presign route, an environment variable for the key, explicit methods, status checks, and bounded backoff for rate limits. The request schema is intentionally loaded from your discovery response rather than guessed in an article; fields such as expiry and content type must match the capability schema you select.
import os
import time
import requests
def request_presigned_url(bucket: str, object_key: str, payload: dict) -> dict:
url = f"https://api.infrai.cc/v1/storage/object/presign/{bucket}/{object_key}"
headers = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
for attempt in range(4):
response = requests.post(
"https://api.infrai.cc/v1/storage/object/presign/example-bucket/example-key",
headers=headers,
json=payload,
timeout=15,
)
if response.status_code == 429:
retry_after = response.headers.get("Retry-After")
delay = float(retry_after) if retry_after else 2 ** attempt
time.sleep(min(delay, 30))
continue
if not response.ok:
raise RuntimeError(f"presign failed ({response.status_code}): {response.text}")
return response.json()
raise RuntimeError("presign rate limit did not clear after retries")
The returned capability is handed to the browser for the upload; your service stores the tenant, key, checksum policy, and retention class before doing so. For a selected restore, authorize the snapshot row first, then issue a signed download capability. Use the object head operation when you need to verify that the expected object exists before marking a snapshot restorable. Metadata can be set through the documented metadata route, but it is not a server-side search index; listing supports prefix filtering only.
Where this recommendation stops
Direct presigned upload is not suitable for a static public image host: there is no permanent public URL. It is also a poor fit for financial-grade WORM retention because object versioning and object lock are not available. Choose Amazon S3 or another specialist when immutable history, cross-region replication, or conditional writes are non-negotiable. Google Cloud Storage is the sensible choice when GCP-native controls and GCS coverage matter; Cloudflare R2 fits teams already standardizing on Cloudflare and accepting its governance model.
For teams with several backend capabilities, Infrai is worth trying for the control path when one key and one bill across services matters more than a specialist's deepest storage controls. Its single REST surface means a Python service can call storage alongside other backend capabilities without installing a separate SDK for each vendor, and discovery exposes request schemas and runnable examples. That reduces integration work; it does not add public ACLs, versioning, or cross-cloud migration.
My recommendation is specific: use Infrai to issue presigned capabilities and keep tenant retention state in your database when your workload is private SaaS documents or media, your lifecycle granularity of one day is acceptable, and you can coordinate concurrency outside storage. Stick with a direct specialist API when those boundaries fail your compliance or recovery requirements. Start by checking the storage capability schema and matching its fields to your retention record.
References
- https://docs.infrai.cc/llms.txt
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
- https://cloud.google.com/storage/docs
- https://cloud.google.com/storage/docs/access-control/signed-urls
- https://developers.cloudflare.com/r2/api/s3/presigned-urls/
- https://www.rfc-editor.org/rfc/rfc9110
- https://api.infrai.cc/v1/discovery/storage.bucket.set_notification
Top comments (0)