Skip to the page
Social CrawlDocs

Storage, WebDAV and R2

Updated
View as Markdown

Where saved files live, how to keep them in Cloudflare R2, and how to offload large files and whole copies to your own WebDAV storage.

On this page

Your saved files (pictures, videos, ZIP pages) live in one of three places. Posts and tags are in the database, not here.

PlaceWhenHow to set it up
The server's diskThe default. Files sit in the bundles volume.Nothing to do.
Cloudflare R2 (or any S3-compatible bucket)You want the files off the server.Environment variables, below.
Your WebDAV storageYou want large files or full copies kept elsewhere, next to the main storage.Settings → Storage → WebDAV storage.

The main storage is the disk or R2. WebDAV is always an addition to it.

Use Cloudflare R2#

R2 offers 10 GB free. Create a bucket and an access key limited to that bucket, then set these in Dokploy's Environment and redeploy:

Text
STORAGE_DRIVER=s3
S3_ENDPOINT=https://<account id>.r2.cloudflarestorage.com
S3_BUCKET=social-crawl-media
S3_REGION=auto
S3_ACCESS_KEY_ID=...
S3_SECRET_ACCESS_KEY=...

All four of S3_ENDPOINT, S3_BUCKET, S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY are needed once the driver is s3, and the endpoint must start with https://, or the server refuses to start and says which is missing.

The bucket stays private. The server streams files out of it, with range support for video seeking, so your login still protects everything.

Posts already on the disk are copied once with this command, run with the S3 settings in place:

Terminal
docker exec <api container> node apps/api/dist/scripts/migrate-storage.js

It can be run again and leaves the disk files untouched. Remove STORAGE_DRIVER to go back to the disk.

Use WebDAV#

WebDAV is a protocol many cloud storages speak (Nextcloud, ownCloud and others). Social Crawl uses it for large files, and to keep a full copy of a post.

Set it up#

  1. Open Settings → Storage → WebDAV storage.
  2. Fill in WebDAV folder address (it must start with https://; http:// is accepted only for localhost, and the address must not contain a user name or password), User name and Password.
  3. Press Test connection. It lists the folder, creates a social-crawl folder, writes a small file, reads it back and deletes it, and tells you which step failed. A message such as "wrong user name or password?" means a 401, and "is the address the WebDAV folder?" means the address was not found.
  4. Turn on Store large files on WebDAV and set Large file size (MB) (25 by default).

What goes there#

With the switch on, new videos and sound files, and any file from the size limit up, are written to <WebDAV folder>/social-crawl/<platform>/<id>/ instead of the main storage. Files already saved stay where they are. Each bundle keeps a small .webdav.json on the main storage that says which of its files are on WebDAV. Playing a video (with seeking), the ZIP download and frame export read a file from whichever side it is on, and deleting a post deletes its files on both sides. If an upload to WebDAV fails while a post is saved, that file goes to the main storage instead, and the server log says so.

Per post#

A post has a storage menu in its toolbar. Its name says where the post is (for example "On WebDAV"), or just Storage. At the top it counts the files and bytes on each side, for example "WebDAV: 3 files (1.2 GB)", and adds "plus a full copy on WebDAV" when there is one. It offers four actions:

ActionWhat it does
Keep only on WebDAVMoves everything to WebDAV, then deletes it from the main storage. Off until WebDAV is set up.
Keep only on the main storageBrings everything back from WebDAV, then deletes it from WebDAV.
Save a copy to WebDAVA full copy of every file, kept on both sides, for safekeeping. Deleting the post deletes the copy too, and saving the post again replaces it.
Move large files to WebDAVVideos and big files leave the main storage. For posts saved before WebDAV was set up.

The two "Keep only" actions ask you to confirm first. All four run on the server and report progress, and closing the window does not stop them. With WebDAV not set up the actions are greyed out and the menu offers Open Settings.

The password#

The password is stored encrypted (AES-256-GCM, with a key made from JWT_SECRET) and is never sent back to the browser. If JWT_SECRET changes, the saved password can no longer be read: enter it again in Settings. Until then, files on WebDAV cannot be read.

Playing from WebDAV#

Playing or jumping about in a large video asks WebDAV only for the parts you watch. The server keeps those parts on its own disk (VIDEO_CACHE_MB, 2048 by default; 0 turns it off) and removes the least recently used ones when it is over, and parts nobody used for a day. A part that is playing is never removed.

Back up#

Back up the two Docker volumes: bundles (saved files) and pgdata (the database). If you use R2 or WebDAV, back those up in their own way.