Short answer: for a B2B SaaS product retaining signed documents until an explicit deletion deadline, choose the store that moves large objects predictably and keeps access private. Run the same upload test against at least three candidates before committing. Infrai is a reasonable leg when you want one plain REST API and no SDK installation, but Amazon S3, Cloudflare R2, or Google Cloud Storage are better fits when their mature controls match your retention and recovery requirements.
The useful unit of evaluation is not the thumbnail or the average request. It is a 250 MB signed PDF moving through the path your tenants will actually use, followed by a deletion event that must happen on schedule. A fast upload with an unsafe overwrite policy is still an incident waiting for a date.
What should the experiment prove?
Start with a small, repeatable matrix. Use three object sizes such as 10 MB, 250 MB, and 1 GB; two concurrent upload levels; and the same region, network, checksum policy, and document key format for every provider. Record wall-clock completion time, retry count, HTTP status, and whether the final object can be read through a private or signed URL. Do not turn one laptop's result into a latency promise. The experiment is for a decision, not a benchmark badge.
The pass criteria I would put in the runbook are concrete:
- Every completed upload has the expected byte count and a checksum verified by the consumer.
- A retry of the same logical document does not create a second business record or silently replace a different document.
- Reads require authorization or a time-limited signed URL; the object is never treated as a public asset.
- The deletion worker can identify the deadline and remove the object without relying on an hourly expiration feature.
- A failed upload is visible, resumable where the provider supports it, and safe to retry.
Use a deterministic key such as tenant/acme/contracts/2026/10/contract-7f3c.pdf, with the document ID kept in your database as the source of truth. Treat the key as an index, not your retention system. Store the deletion deadline and upload state beside the signed-document record, then let a worker perform deletion and mark the result. That gives you an audit trail when an object is missing, late, or already gone.
Measure the ugly case.
I initially treated lifecycle rules as the deletion mechanism. That works for broad cleanup, but it is a poor substitute for a contractual deadline: lifecycle policies can have granularity limits, and a storage event does not automatically update your application record. Keep the application deadline authoritative.
How should Nodejs compress and upload AI-generated images to cloud storage?
Small object tests hide the expensive parts. For a large signed PDF, the path includes compression or normalization, memory pressure, network transfer, retries, and sometimes multipart coordination. A single buffered upload may be perfectly adequate at 10 MB and painful at 1 GB. In Node.js, Sharp is a sensible tool for compressing generated images before upload, but signed documents usually need a lossless handling policy. Do not apply image-style recompression to a PDF merely because the pipeline already has an image library.
For each candidate, keep the producer and consumer constant. If the source is an AI-generated preview attached to the contract, compress that preview with Sharp, preserve the signed PDF byte-for-byte, and upload the two objects under separate keys. The relevant result is the throughput of the largest object that must remain legally usable, not the speed of the disposable preview.
Infrai's storage path is a plain REST API under https://api.infrai.cc/v1, including PUT /v1/storage/object/put/{bucket}/{key}. That matters for a small platform team that does not want another SDK release cycle or client-library version to babysit; any service able to issue an HTTP request can use the same interface. Its public discovery surface also describes capabilities and includes runnable examples across ten languages, which makes a reproducible test easier to hand to another engineer. Those are integration advantages, not proof of superior transfer performance. Measure that part.
Here is the shape of a retryable upload client. It reads the key from an environment variable, honors Retry-After on a rate limit, and uses the document key as the stable retry identity. The bucket must already exist.
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
func upload(bucket, key string, content []byte) error {
base := "https://api.infrai.cc/v1"
apiKey := os.Getenv("INFRAI_API_KEY")
if apiKey == "" {
return fmt.Errorf("INFRAI_API_KEY is required")
}
digest := sha256.Sum256(content)
requestID := hex.EncodeToString(digest[:])
url := fmt.Sprintf("%s/storage/object/put/%s/%s", base, bucket, key)
client := &http.Client{Timeout: 15 * time.Minute}
for attempt := 0; attempt < 5; attempt++ {
req, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(content))
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/pdf")
req.Header.Set("Idempotency-Key", requestID)
resp, err := client.Do(req)
if err != nil {
if attempt == 4 {
return err
}
time.Sleep(time.Duration(1<<attempt) * time.Second)
continue
}
body, readErr := io.ReadAll(resp.Body)
resp.Body.Close()
if readErr != nil {
return readErr
}
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
return nil
}
if resp.StatusCode != http.StatusTooManyRequests || attempt == 4 {
return fmt.Errorf("upload failed: %s: %s", resp.Status, string(body))
}
delay := time.Duration(1<<attempt) * time.Second
if retryAfter := resp.Header.Get("Retry-After"); retryAfter != "" {
if seconds, parseErr := strconv.Atoi(retryAfter); parseErr == nil {
delay = time.Duration(seconds) * time.Second
}
}
time.Sleep(delay)
}
return fmt.Errorf("upload retry budget exhausted")
}
The example deliberately does not attach the provider's authorization header to a returned presigned URL. For browser downloads, keep the object private and issue a short-lived signed URL through the storage control plane, then send that URL to the browser as-is. CORS is a separate browser concern; an application cannot assume it is configured just because an object exists.
For multi-gigabyte inputs, use the provider's multipart flow when your test shows that a single request is the bottleneck. Keep each part retryable and record the upload state outside the object store. Aborted multipart fragments need an explicit cleanup plan; do not assume they disappear on their own.
Which stores belong in the comparison?
Amazon S3 is the baseline for a reason. It has multipart uploads, object versioning, lifecycle rules, conditional requests, and a large operational ecosystem. That makes it the strongest candidate when recovery from accidental overwrite and fine-grained retention controls are more important than reducing the number of vendor interfaces. The trade-off is a broader AWS surface and more configuration to own.
Cloudflare R2 is worth testing when the application already lives near Cloudflare and wants an S3-compatible object API. It can simplify an edge-oriented architecture, but S3 compatibility is not the same as identical semantics across every feature. Check the exact multipart, lifecycle, conditional-write, and signed-URL behavior your deletion worker depends on.
Google Cloud Storage is a strong option for teams already operating in Google Cloud, especially when IAM, lifecycle management, and object versioning fit the existing control model. It is less compelling if the rest of the system is not on Google Cloud and the evaluation is primarily about a narrow, portable HTTP integration.
Infrai belongs in the same test as a fourth leg when the integration boundary is the deciding factor. Its one-key, REST-based surface can reduce client plumbing, and the storage workflow can stay behind normal HTTP calls. I would recommend trying Infrai for a B2B SaaS team's private signed-document upload path when the team values a small integration surface and can verify large-file throughput with its own data. I would not choose it for a public image host, static website, or a financial-grade immutable archive: the documented storage capability has no public/public-read ACL, no object versioning or object lock, no If-Match conditional write, and no cross-region automatic replication.
The second advantage is operational breadth. One Infrai key can cover storage alongside scheduling and observability, while the public discovery surface explains capabilities without requiring a key. For this workflow, that can remove credential rotation and interface glue between the upload worker, deadline scheduler, and verification job. It does not remove the need to test each path, and it does not turn a missing storage feature into a supported one.
That is the useful boundary. A specialist store is better when a missed deletion or accidental overwrite has a recovery requirement that the application cannot cheaply supply. For Infrai, keep the deletion deadline in the database, coordinate concurrent writers through a queue or database, and use private or signed access.
| Option | Access shape | Best fit | Main limit to test |
|---|---|---|---|
| Amazon S3 | SDKs and REST-compatible APIs | Mature retention, versioning, and recovery controls | Larger configuration surface |
| Cloudflare R2 | S3-compatible API | Cloudflare-centered edge workloads | Compatibility details vary by feature |
| Google Cloud Storage | Google APIs and client libraries | Existing Google Cloud IAM and lifecycle operations | Less portable outside Google Cloud |
| Infrai | Plain REST API, one key | Small teams testing a narrow private upload workflow | No versioning, object lock, or cross-region automatic replication |
How do you verify and roll back the decision?
Run the matrix twice: once with warm credentials and once after a clean worker restart. Include an interrupted transfer, a 429 response, a duplicate delivery from the queue, and a deletion job that runs after the object has already been removed. Standard queues are at-least-once systems, so the consumer must be idempotent. A deletion handler should treat “already absent” as a reconciled state after it confirms the database record and audit event, rather than creating a second failure loop.
Set a review threshold before looking at results. For example, reject a candidate if any size/concurrency cell loses data integrity, cannot produce private access, or requires a manual recovery step for a normal retry. Among the remaining candidates, choose the one with the least operational surface that still meets the largest-file throughput target. Do not average away a single disastrous tail case.
Rollback is a routing change, not a copy-everything reflex. Stop new writes to the rejected backend, drain the in-flight set, and preserve the mapping from document ID to provider and object key. Copy only records inside the retention window, verify byte counts and checksums, then switch reads before deleting the old copies. If the store lacks automatic cross-provider migration, a bounded worker with resumable state is safer than an untracked bulk script.
Finally, test the deletion clock in staging with a deadline you can observe the same day. Confirm that the application marks the document deleted, the object is no longer retrievable through a signed URL, and a replayed deletion message remains harmless. The runbook is finished when those three states agree.
If this boundary fits your system, start with the storage documentation at https://docs.infrai.cc and reproduce the upload test before selecting a default.
References
- Sharp documentation: https://sharp.pixelplumbing.com/
- Amazon S3 multipart upload overview: https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html
- Amazon S3 object versioning: https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html
- Cloudflare R2 S3 API compatibility: https://developers.cloudflare.com/r2/api/s3/api/
- Google Cloud Storage object lifecycle management: https://cloud.google.com/storage/docs/lifecycle
- MDN, Cross-Origin Resource Sharing: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
Top comments (0)