Files

Every file is a typed record in your schema.

Clients upload bytes straight to object storage. Napalm checks file size and format before marking the record ready, and edge caches serve downloads.

Read the files docs

Direct uploads

Clients upload straight to storage.

Insert a file record setting file_size and select file_upload in one statement. The query returns a presigned upload plan to the caller, and browsers or mobile apps send bytes straight to object storage.

File upload protocol
dbschema/queries/addScan.edgeql
select (insert Scan {  owner := global caller,  file_name := <str>$name,  file_size := <int64>$size,}) { id, file_upload }

Upload checks

Napalm verifies every upload.

A JPEG renamed contract.pdf never becomes Ready. On completion, Napalm checks the byte length and reads the file format from the uploaded bytes. Rejected uploads are deleted.

dbschema/default.gel
using extension files; type ContractPdf extending ext::files::File {  required deal: Deal;  constraint expression on (.file_format = ext::files::Format.Pdf);   access policy deal_members    allow select, insert using ((global caller in .deal.team.members) ?? false);}
Files and object storage

Public files

Serve public files on custom domains.

Overload file_is_public on avatars or catalog media for permanent unsigned URLs, and bind a custom domain over automatic TLS. Public uploads still pass your access rules and format constraints.

dbschema/default.gel
type Avatar extending ext::files::File {  overloaded required file_is_public: bool {    default := true;  };  required owner: ext::auth::Identity;}
Files and object storage

Download links

Download links arrive in your query result.

Select file_url beside your other fields in the same query. Napalm signs private URLs only for records the caller’s access policy admits, and each link stays valid for 6 hours from the nearest edge.

Files and object storage
dbschema/queries/noteAttachments.edgeql
select Note {  title,  attachments: {    file_name,    file_size,    file_url,  } filter .file_status = ext::files::Status.Ready,}

Resumable uploads

Large files upload in verified parts.

napalm.upload splits multi-gigabyte videos and datasets across presigned multipart URLs, tracks upload progress and verifies the bytes on completion.

app/upload.ts
const { data } = await db.POST('/query/addScan', {  body: { variables: { name: file.name, size: file.size } },})const verified = await napalm.upload(data.data[0].file_upload, file, {  onProgress: (sent, total) => setProgress(sent / total),})
TypeScript file uploads

Edge delivery

File downloads cost $0.04 per gigabyte.

Every month includes 500 GB of download bandwidth. Popular objects cache at edge locations near your readers. Deleted files remain in storage until your oldest backup expires, so a branch restore never leaves broken links.

$0.04 / GBfile download bandwidth past 500 GB a month

Pricing