Customer file uploads for SaaS products
Dreep handles the files your customers upload inside your product. Your backend presigns each upload into a folder per tenant, signed URLs keep tenants apart, and OCR reads receipts and invoices without another vendor.
How it works
The tenant always comes from your session, never from the request body.
- 1
User attaches a file
Inside your app
- 2
Your API authorises
tenantId from session
- 3
Presign
tenants/{tenantId}/documents
- 4
Browser PUT, then confirm
Single-use URL
- 5
Signed links
Short expiry per viewer
A backend presign endpoint
One authenticated endpoint presigns uploads, and a helper signs links when a user opens a file.
import { Dreep } from "dreep";
const dreep = new Dreep({
apiKey: process.env.DREEP_API_KEY,
signingSecret: process.env.DREEP_SIGNING_SECRET,
});
// POST /api/uploads/presign (your auth middleware sets req.user)
export const postUploadPresign = async (req, res) => {
const { filename, contentType, sizeBytes } = req.body;
const { tenantId } = req.user; // never trust a tenantId sent by the client
const upload = await dreep.presignUpload({
filename,
contentType,
sizeBytes,
folder: "tenants/" + tenantId + "/documents",
});
return res.json({ id: upload.id, uploadUrl: upload.uploadUrl });
};
// After checking the file belongs to req.user.tenantId
export const fileLink = ({ asset }) => dreep.signedUrl(asset, { expiresIn: 300 });// tenantFromSession is your own auth helper.
tenantID := tenantFromSession(r)
upload, err := client.PresignUpload(r.Context(), dreep.PresignOptions{
Filename: body.Filename,
ContentType: body.ContentType,
SizeBytes: body.SizeBytes,
Destination: dreep.Destination{Folder: "tenants/" + tenantID + "/documents"},
})# Presign an invoice upload for tenant t_42
curl -X POST https://api.dreep.cloud/api/v1/upload/presign \
-H "Authorization: Bearer $DREEP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"invoice-0193.pdf","contentType":"application/pdf",
"sizeBytes":412337,"folder":"tenants/t_42/documents"}'Why SaaS teams use it
Inherited access
A new tenant's folders are Signed from the first upload, because tenants/ is Signed.
OCR and cutouts built in
Read text from receipts with format=txt and remove backgrounds from product shots in the same API.
Explicit limits
Exceeding a plan limit returns LIMIT_EXCEEDED, so one heavy customer cannot run up your bill.
Frequently asked questions
How do I keep one tenant from opening another tenant's files?
Put tenant files under a Signed root such as tenants/, read the tenant from the session, and only issue a signed URL after checking the file belongs to that tenant.
Do our customers need Dreep accounts?
No. Your backend holds the API key and issues upload and download URLs. Dreep team seats are only for your own staff.
Can a customer keep their files in their own S3 bucket?
Yes, with Bring Your Own Bucket on Starter or Pro. Create a dedicated, empty project for that customer and connect their bucket before any upload.
Can the API key live in our frontend?
No. The key must stay server-side. Browsers upload through presigned URLs your backend creates.
Wire up tenant uploads in an afternoon
Create a Signed tenants folder, add one presign endpoint to your API and open an invoice through a short signed link.