Skip to content

Storage Disks, CDN & Private Vaults

Media abstracts physical file storage behind Totoglu\Media\Storage\MediaDiskInterface, DiskRegistry, and FlysystemDisk (league/flysystem v3).

Setup > Media > Disks & Tools monitors storage disks, dispatches background sync jobs, audits Private Vaults, and provides 1-click CDN URL templates.
Disk / Driver Implementation Target / Protocol
public (local_public) LocalPublicDisk site/assets/files/media/ with atomic LOCK_EX writes, symlink rejection, and realpath() containment
private (local_private) LocalPrivateDisk site/assets/media-private/ with .htaccess deny + index.html guard
s3 FlysystemDisk::fromS3Config() Official AWS SDK v3 (league/flysystem-aws-s3-v3) for AWS S3, Cloudflare R2, DigitalOcean Spaces, MinIO, Backblaze B2
sftp FlysystemDisk::fromSftpConfig() SSH/SFTP via phpseclib v3 with password or OpenSSH/PEM private key + passphrase
ftp FlysystemDisk::fromFtpConfig() FTP and FTPS (TLS/SSL, passive mode)
s3_sigv4 S3SigV4Disk Lightweight zero-SDK AWS SigV4 driver over ProcessWire WireHttp
Custom Flysystem v3 FlysystemDisk::fromAdapter() Any League\Flysystem\FilesystemAdapter (Google Cloud Storage, Azure Blob, WebDAV)

Disk Resolution Precedence & Transform Modes

Section titled “Disk Resolution Precedence & Transform Modes”

DiskRegistry::boot() resolves disks in ascending priority (later entries override earlier ones with the same handle):

  1. Built-in local disks (public, private)
  2. Media::registerDiskDrivers hook ($registry->registerDriver() / $registry->registerDisk())
  3. Database media_settings (disks blocks under Setup > Media > Settings > Storage & Disks)
  4. $config->media['disks'] in site/config.php

Each remote disk supports two transform strategies:

  • transform_mode: sync: Generates variations locally in bounded temp cache and uploads them to the remote disk.
  • transform_mode: cdn_template: Emits zero-CPU CDN proxy URLs using {path}, {width}, {height}, {format}, {focus_x}, {focus_y}, {quality}, and {version} placeholders. Setup > Media > Disks & Tools provides 4 ready-to-copy presets (query_params, edge_directive, path_segments, resize_proxy).

Module-Scoped Private Vaults (uploadPrivate)

Section titled “Module-Scoped Private Vaults (uploadPrivate)”

Use Private Vaults to store confidential module-owned files (form attachments, customer invoices, identity documents) completely isolated from the public editorial library:

<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\Media\Entity\MediaAssetItem;
$media = $this->wire()->media;
// 1. Store inside private vault (visibility='private', hidden_from_library=true, owner='forms')
$doc = $media->uploadPrivate('forms', '/tmp/applicant-passport.pdf', [
'title' => 'Applicant Passport',
'custom_meta' => ['submission_id' => 1042],
]);
// 2. Register fail-closed owner authorization policy
$media->registerOwnerPolicy('forms', function (MediaAssetItem $asset, User $user, array $context): bool {
return $user->isSuperuser() || $user->hasPermission('forms-submissions-view');
});
// 3. Mint an HMAC-SHA256 signed download URL with optional single-use JTI replay protection
$downloadUrl = $doc->signedUrl(300, ['singleUse' => true]);

Requests to /_media/download/{token} verify the HMAC-SHA256 signature and TTL, check single-use JTI replay protection, evaluate the owner policy / Media::authorizePrivateAsset hook, and stream the file with Cache-Control: private, no-store, X-Content-Type-Options: nosniff, X-Robots-Tag: noindex, nofollow, and RFC 9110 HTTP Range support (plus optional X-Accel-Redirect / X-Sendfile).

  • Admin Vault Audit: Users with media-admin can inspect private vault metadata filtered by owner module under Setup > Media > Disks & Tools (vault-list) and mint single-use 5-minute audit links (vault-sign), logged to ProcessWire’s media log channel.
  • Owner Cleanup: Call $this->wire()->media->purgeByOwner('forms') when uninstalling a module or purging records to delete all owned vault assets in one operation.

Next steps