File storage

Store customer files and sell downloads without a storage account

Your backend asks TenancyEngine for a short-lived upload URL and sends the file straight to it. You never hold a cloud storage key.

Needs an API key with the storage scopes you use (storage.read, storage.write, storage.grants.write). Storage limits are set on your plans.

What you get

Four ways to share a file

Private to one person, shared with everyone in a customer workspace, a public preview, or a paid download that only a buyer can fetch.

Paid downloads done right

Upload the file privately, grant read access to the purchase, and ask for a download URL only after your app has rechecked the payment. A grant can expire and can be revoked.

Customer files stay with the customer

Files uploaded from a customer’s portal belong to that customer’s workspace. Files your backend uploads belong to your app and stay private until you decide otherwise.

Limits and clean-up

Set a maximum file size and a retention period for each bucket, and watch the file count and bytes stored in the console.

In your code

These calls come from the TenancyEngine.Sdk package on NuGet. Every capability is also a REST API, so any language that can make an HTTPS request can use it.

Sell a download
using System.Net.Http.Headers;

// 1. Ask for an upload URL for a private file you will sell.
var upload = await te.RequestStorageUploadUrlAsync("my-app",
    TenancyEngineStoragePatterns.PurchasedDownloadUpload("bundle.zip", "application/zip"), ct);

// 2. Send the bytes to that URL, then confirm the upload.
using var put = new HttpRequestMessage(HttpMethod.Put, upload.UploadUrl)
{
    Content = new ByteArrayContent(bytes),
};
put.Content.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
(await http.SendAsync(put, ct)).EnsureSuccessStatusCode();
await te.ConfirmStorageUploadAsync("my-app", upload.ObjectId, ct);

// 3. After a purchase, grant that purchase read access for two hours.
await te.CreateStorageGrantAsync("my-app",
    TenancyEngineStoragePatterns.PurchasedDownloadGrant(
        upload.ObjectId, purchaseId, DateTimeOffset.UtcNow.AddHours(2)), ct);

// 4. When the buyer asks, and your app has rechecked the payment:
var downloadUrl = await te.GetStorageDownloadUrlAsync("my-app", upload.ObjectId,
    TenancyEngineStoragePatterns.PurchasedDownloadUrl(purchaseId), ct);

What to know before you build on it

  • Your app decides who may download a paid file. TenancyEngine checks the grant, not your payment records.
  • Upload and download with an API key from your backend only. Never put the key in a browser or a mobile app.
  • Deleting a bucket permanently deletes every file in it.

Questions developers ask

Do I need my own cloud storage account?

No. Uploads and downloads go through short-lived URLs that TenancyEngine issues for your app.

How do I let only paying customers download a file?

Keep the file private, create a grant tied to the purchase, and request a download URL only after your app has confirmed the payment is still good.

Can I remove files automatically?

Yes. Set a retention period on a bucket and files are deleted after that many days.

Try it on the free Starter plan

One app and up to five customer workspaces. Upgrade when you need more.

Request access