# Files

URL: https://qrdx.dev/docs/files
Source: https://github.com/qrdxinc/qrdx/blob/main/apps/docs/content/docs/files.mdx

Upload PDFs, images, audio and video for your hosted pages, replace a file behind the same link, and set up file storage when you self-host.

Hosted pages can show files you upload to QRdx: a menu or brochure as a PDF, a photo gallery, music or a podcast, or a video. Uploaded files live in **Files** in the sidebar, belong to the workspace you upload them in, and each one has a stable link that keeps working when you replace the file. Use them when the file has no home of its own, or when you want to swap next season's menu without touching the page.

**Plans**

Free includes 50 MB of storage per workspace with files up to 10 MB; Pro 5 GB and 100 MB; Business 50 GB and 250 MB. See [Plans and limits](https://qrdx.dev/docs/plans-and-limits).

## How it works [#how-it-works]

Your browser uploads the file straight to the storage bucket. QRdx then checks it (its size, and that its first bytes really are a file of its type), copies the checked version to the file's own place and gives it a link, `https://qrdx.dev/api/files/<id>`. Pages and codes use that link, which is why replacing the file changes nothing for them.

## What you can upload [#what-you-can-upload]

| Kind | Formats |
| --- | --- |
| PDF | PDF |
| Images | JPEG, PNG, WebP, GIF, AVIF |
| Audio | MP3, M4A, AAC, Ogg, WAV |
| Video | MP4, WebM, MOV |

MP4 with H.264 video plays in every browser. MOV files from phones usually play too, but convert them to MP4 if a browser can't play one. SVG, HTML, archives and office documents can't be uploaded, so nothing served from storage can run code in a visitor's browser.

Every upload is checked before it's used: its size must match what was announced, and its first bytes must really be a file of its type (an HTML page renamed to `.pdf` is rejected). Rejected uploads are deleted from storage and listed as **Blocked**.

## Use files on a page [#use-files-on-a-page]

Five blocks show files. Each one can use an uploaded file or a link to a file hosted somewhere else:

- **PDF** shows an uploaded document inline on tablets and computers, with **Open PDF** (a full-screen viewer on phones) and an optional download button. A PDF linked from another site gets the **Open PDF** button. For a QR code that opens a PDF, start from the [PDF QR code generator](https://qrdx.dev/qr-code-generator/pdf).
- **Gallery** shows photos in a grid of 1 to 3 columns. Tapping a photo opens it full screen; swipe or use the arrow keys to browse.
- **Audio** plays tracks with cover art and a playlist; the next track starts when one ends. A download button is optional.
- **Video file** plays an MP4 or WebM you upload, optionally muted on a loop like a GIF. For YouTube, Vimeo or Loom, use the **Video** block instead: it embeds the video without loading anything from the video site until someone taps play.
- **Downloads** lists files people can save, each with its own label.

The **PDF**, **Images**, **MP3 / Audio**, **Video** and **Playlist** page types in **New code** start you with these blocks already in place.

In a block, choose **Upload** to add a file from your device, **From your files** to reuse one you uploaded before, or paste a link.

## Replace or delete a file [#replace-or-delete-a-file]

Open **Files** in the sidebar and use the menu next to a file:

- **Copy link** copies the file's own link (`https://qrdx.dev/api/files/<id>`). You can also use it as the destination of a dynamic QR code.
- **Replace file…** uploads new content behind the same link, for example next season's menu. Pages and codes that use the file show the new version within a minute. A file can only be replaced by one of the same kind (a PDF by a PDF).
- **Delete** removes the file for good. If pages or codes still use it, QRdx lists them first; after deleting, those pages show "File unavailable" where the file was.

![The Files page of a workspace, where PDFs, images and other files for codes and pages are uploaded, with its Choose files button.](https://qrdx.dev/docs-static/shots/files-page.light.webp)

Members can replace and delete the files they uploaded; owners and admins can manage every file in the workspace.

## Reported files [#reported-files]

Every hosted page has a **Report abuse** link. If a file breaks the rules or a copyright owner asks for it to be removed, QRdx can block it. A blocked file stops being served on every page and through its QRdx link within a minute (pages show "File unavailable"), and identical copies of it (up to 25 MB) can't be uploaded again.

## Limits and plans [#limits-and-plans]

| Plan | Storage per workspace | Largest file |
| --- | --- | --- |
| Free | 50 MB | 10 MB |
| Pro | 5 GB | 100 MB |
| Business | 50 GB | 250 MB |

A workspace uses the best plan among its owners and billing members. Limits only stop new uploads: after a downgrade, or when a workspace is over its storage, every file you already uploaded keeps being served on every page that uses it. Delete files you no longer need (or upgrade) to upload new ones. An upload that never finishes stops counting toward storage after two hours.

## For developers [#for-developers]

Files are uploaded and managed in the dashboard. On the API side, a code's design can use an uploaded logo by its file id: see [logos in a code's style](https://qrdx.dev/docs/developers/rest-api#code-logos).

## Set up storage (self-hosting) [#set-up-storage-self-hosting]

File uploads use [Cloudflare R2](https://developers.cloudflare.com/r2/). Without it, the Files page says uploads aren't available, the upload API answers `503` with "Storage not configured on this server.", the five upload page types are hidden from the picker, and blocks can still use links to files hosted elsewhere.

1. In the Cloudflare dashboard, open **R2** and create a bucket, for example `qrdx-files`.
2. Under **R2** → **Manage API tokens**, create a token with **Object Read & Write** on that bucket.
3. Set these environment variables and restart:

   ```bash title="apps/app/.env.local"
   R2_ACCOUNT_ID=your-cloudflare-account-id
   R2_ACCESS_KEY_ID=token-access-key-id
   R2_SECRET_ACCESS_KEY=token-secret-access-key
   R2_BUCKET=qrdx-files
   # Optional: serve files from a public bucket URL or custom domain
   R2_PUBLIC_BASE_URL=https://files.example.com
   ```

4. Add a CORS policy to the bucket (**Settings** → **CORS policy**). Browsers upload straight to R2, so the bucket must accept `PUT` requests with a `Content-Type` header from your app's origin:

   ```json title="R2 bucket CORS policy"
   [
     {
       "AllowedOrigins": ["https://qrdx.example.com", "http://localhost:3000"],
       "AllowedMethods": ["PUT", "GET", "HEAD"],
       "AllowedHeaders": ["Content-Type"],
       "ExposeHeaders": ["ETag"],
       "MaxAgeSeconds": 3600
     }
   ]
   ```

   Replace `https://qrdx.example.com` with the origin people use to open your dashboard (scheme and host, no trailing slash). Keep `http://localhost:3000` only if you upload from a local development server.

### Public files or presigned links [#public-files-or-presigned-links]

Visitors always open files through `/api/files/<id>`, which redirects to the stored object:

- With `R2_PUBLIC_BASE_URL` set (a custom domain connected to the bucket, or its `r2.dev` URL, which Cloudflare rate-limits and recommends for testing only), it redirects to the public URL. Object keys contain a random id, so files can't be listed or guessed.
- Without it, the bucket stays private and every redirect is a presigned link that expires after an hour.

Either way, a replaced, deleted or blocked file stops being served through its QRdx link within a minute. A blocked file also leaves its public URL at once: its object moves to a `quarantine/` key with a random part (kept so an admin can restore it), and its QRdx link answers `410 Gone`.

Browsers upload to a `staging/` key. Once the upload is checked, QRdx copies exactly the checked version to the file's own key, so an upload link that is still valid can't replace a checked file.

**Clean up abandoned uploads**

An upload that never finishes stops counting toward storage after two hours and is cleaned up the next time someone uploads to that workspace. Add an object lifecycle rule to the bucket (**Settings** → **Object lifecycle rules**) that deletes objects with the prefix `staging/` after one day, so leftovers from abandoned uploads go away too.

## Related [#related]

- [Landing pages](https://qrdx.dev/docs/landing-pages): the blocks that show files
- [Plans and limits](https://qrdx.dev/docs/plans-and-limits): storage per plan
- [Self-hosting](https://qrdx.dev/docs/self-hosting#optional-services): every optional service
