Approved, not published yet. Visible on the preview site only.

Send and receive large client files with your own Nextcloud

Use Nextcloud for client files: upload-only drop links, read-only delivery links and one email when files move. Setup steps, costs and the mistakes worth avoiding.

Software8 min read

Close view of the drive bays on a small storage box

A client sends a few hundred gigabytes of footage through a transfer link. The link expires after a week. A fortnight later they ask for a re-edit, and the footage is gone.

We wanted something calmer: one place per project, a link the client can drop files into without an account, a separate link for finished work, and an email when something actually moves. This post shows how to build that with Nextcloud, a free, self-hosted file cloud.

Why bother, and when not to

Transfer services suit a one-off handover. Video, design and print projects go back and forth for weeks.

  • Links expire, which is exactly wrong when a client asks for changes a month later.
  • There is no home for the project. Files live in whichever inbox the link landed in.
  • You do not know when things arrive, or when a client has finished uploading.
  • Size limits and monthly fees for files that mostly sit idle.

When not to do this: if your files are small, a normal cloud drive is fine. If nobody in the business is comfortable looking after a server, updating it and checking backups, a paid service is the safer choice.

What you need

Prices are approximate.

  • A small server that stays on. A mini PC is plenty: roughly ₹15,000 to ₹25,000 new, or ₹8,000 to ₹15,000 used.
  • A small SSD for the database, separate from the big file drive.
  • A large separate drive for the files. A 4 TB external or internal drive is roughly ₹8,000 to ₹14,000.
  • An internet line with real upload speed. At 40 Mbps upload, 100 GB takes about 6 hours; under 20 Mbps a transfer service will beat you. Most home and office lines also change public IP, so budget for dynamic DNS or a tunnel service.
  • A domain name, roughly ₹800 to ₹1,500 a year, so links look like your business.
  • A UPS for the server, roughly ₹3,000 to ₹6,000. Optional.
  • Software, all free: Docker, Nextcloud, MariaDB, Redis and a reverse proxy. We use Caddy.
  • Optionally, something to automate it. In our case a small Django portal that creates folders and links per project and sends the emails.
How the pieces connect: the client's browser, the reverse proxy, Nextcloud, the storage drive and the portal that creates links and sends emails
How the pieces connect: the client's browser, the reverse proxy, Nextcloud, the storage drive and the portal that creates links and sends emails

How to set it up

1. Run Nextcloud in Docker, with the version pinned. One Compose file with the official Nextcloud image, MariaDB and Redis. Files go on the big drive, the database on the SSD.

services:
  app:
    image: nextcloud:<exact-version>      # pin it, never :latest
    volumes:
      - /mnt/<big-drive>/nextcloud:/var/www/html
    environment:
      MYSQL_HOST: db
      REDIS_HOST: redis
  db:
    image: mariadb:<version>
    volumes:
      - /srv/<fast-disk>/nextcloud-db:/var/lib/mysql
  redis:
    image: redis:alpine

Exclude Nextcloud and its database from any automatic container updater. When it works, docker compose up -d starts three containers and the setup page loads.

2. Put it behind a reverse proxy. With Caddy the block is a few lines:

files.example.com {
    reverse_proxy <nextcloud-container>:<port>
}

Add the name to trusted_domains in Nextcloud's config. When it works, the login page loads over HTTPS with a valid certificate and no warning.

3. Switch background jobs to cron. By default Nextcloud runs housekeeping only when someone loads a page. Add a cron line on the host:

*/5 * * * * docker exec -u www-data <nextcloud-container> php -f /var/www/html/cron.php

Then set background jobs to "Cron" in the admin settings. When it works, that page shows a last-run time of a few minutes ago.

4. Do the day-one basics. In Administration settings, Sharing: tick Set default expiration date and Enforce expiration date, enter 30 days, and tick Enforce password protection if you want it. In Administration settings, Security: enable the TOTP two-factor app and tick Enforce two-factor authentication. You know it worked when a new share dialog already shows an expiry and the next login asks for a code.

5. Make the two kinds of public link. A public link lets someone with no account reach a folder, and its setting decides what they can do. In Files, open the project's 01 Incoming folder, click Share, press + next to Share link, open the link's three-dot menu and choose File drop (upload only), then set an expiry. For 02 Delivery make a second link and leave it on View only. When you script it, those are the same two choices as permission numbers:

  • Upload link (file drop): permission 4, "create only". The client can add files and nothing else. They cannot see, download or delete what is there, so one client never sees another's material.
  • Delivery link (read only): permission 1. The client can browse and download, nothing else.

Our portal sets upload links to expire after 14 days and delivery links after 30. The project folder itself never expires, only the links, so a request in two months just needs a fresh link to the same folder. When it works, opening the upload link in a private window shows a drop area and no file list.

The upload page a client sees: a drop area and a button, with no list of existing files
The upload page a client sees: a drop area and a button, with no list of existing files

6. Automate it (optional). Our portal logs in as its own non-admin Nextcloud user with an app password, so a bug in the portal cannot reach anyone else's files. Each project gets Clients/<client>/<project code>/01 Incoming and 02 Delivery, created over WebDAV. Links come from the share API:

curl -u <portal-user>:<app-password> \
  -H "OCS-APIRequest: true" -H "Accept: application/json" \
  -d path="/Clients/<client>/<code>/01 Incoming" \
  -d shareType=3 -d permissions=4 -d expireDate=<yyyy-mm-dd> \
  https://files.example.com/ocs/v2.php/apps/files_sharing/api/v1/shares

shareType=3 means a public link. When it works, the JSON response includes the link and a share ID; store the ID so the link can be deleted later.

7. Email when files move. Our portal runs a small background service that wakes every five minutes and asks Nextcloud's activity API for anything newer than the last event it saw: a GET to /ocs/v2.php/apps/activity/api/v2/activity/all?since=<last id> with the header OCS-APIRequest: true. That last id is the cursor, one integer kept in the portal's database. It looks for public-link uploads into 01 Incoming and downloads from 02 Delivery. To avoid 200 emails for 200 clips, it waits for a quiet spell, then sends over ordinary SMTP:

  • Staff: one email per upload batch, after 10 quiet minutes, with file names and sizes.
  • Client: a receipt after 30 quiet minutes, at most one every six hours per project.
  • Client: an email when we drop a delivery in 02 Delivery, with the link and expiry.
  • Staff: a download email so we know the delivery landed.

When it works, a test upload of three files produces one staff email listing all three. Without a portal you can get most of this from Nextcloud alone: in Personal settings, Activity, tick email for file created and choose "as soon as possible". You get one email per file.

One notification email listing every file that arrived in a batch, with sizes
One notification email listing every file that arrived in a batch, with sizes

8. Back up and set a retention rule. Back up the database, config.php and the data folder every night, ideally to a separate machine. Ours runs from one cron line overnight: a mariadb-dump --single-transaction of the database and a copy of config.php to a NAS drive. We do not copy the data folder, because for us Nextcloud is itself the second copy of files that live on our own machines. If it holds the only copy of a client's raw footage, back the folder up too, with rsync to another disk. Restore it once into a throwaway container; if the login page comes up and the folders are there, the backup is real.

Decide a retention period on purpose and tell the client in writing. Our default is to delete a project's files 30 days after it closes, with a warning email to the client a week before. Deleted files then sit in Nextcloud's trash for up to 30 more days unless you shorten trashbin_retention_obligation.

What goes wrong

  • Links show the wrong name. A setting called overwritehost forces every share link onto one name. Remove it and list every name you serve in trusted_domains.
  • The upload link lets clients see everything. The share API accepts an older flag, publicUpload, which sounds right but widens the link to read and upload. Use permission 4 and leave that flag out.
  • The disk fills with junk. With background jobs left on the default mode, housekeeping falls behind and abandoned upload chunks can grow to gigabytes. Switching to cron clears the backlog in minutes.
  • PHP settings are ignored. PHP reads config files in alphabetical order, so 99-tuning.ini can lose to a file that sorts later. Name it zz-tuning.ini so it loads last.
  • A script fails on huge files. Browsers upload in chunks; our 6 GB test file arrived with matching checksums. A script sending one large request is refused: the official image caps a single request at about 1 GB (APACHE_BODY_LIMIT), and PHP's own upload limit is 512 MB by default (PHP_UPLOAD_LIMIT). Send it in chunks. Nextcloud's chunked upload is a WebDAV sequence (MKCOL under remote.php/dav/uploads, PUT numbered chunks, MOVE to the final path), or just use the desktop client or rclone, which chunk for you.
  • The upload dies at 60 percent. A browser file drop does not resume after a page reload or a router restart; the client starts again and the half-uploaded chunks sit on disk until cron clears them. Ask clients to upload in batches of a few files, and give regular clients the desktop client or rclone, which resume.
  • The notifier misses events. Nextcloud prunes old activity. A 304 reply just means nothing is new, but if the job is down long enough that its stored id has gone, Nextcloud quietly starts from its oldest entry instead. Ours spots that and walks back from the newest entry to the stored id. After any long outage, compare the folder listing with the last file list you emailed.
  • An upgrade stops halfway. Nextcloud must go up one major version at a time. Turn on maintenance mode, dump the database and archive the web folder before each step. If PHP crashes mid-upgrade, running occ upgrade by hand usually finishes it.

Cost and time

The software is free. The hardware above comes to roughly ₹25,000 to ₹45,000 if you buy everything new, far less if a machine already stays on. Expect an afternoon for steps 1 to 5 if you are comfortable with Docker, and a few days of part-time work for the automation and emails. After that, you pay for electricity, the domain and an hour per upgrade.

The short version

One folder per project, an upload link that only accepts files, a delivery link that only gives them, and one email when something moves.

We built this into the project portal we use for our own work. If you want something like it for your business, see what we build.

Written by Siddharth Agrawal, Founder and Director, TDH Systems.

Tell us what you have in mind. We will come back with a plan and a quote.

Start a project

Prefer email? Write to info@thydarkhour.com.