File Manager
The File Manager is responsible for securely downloading the upscaled image from the Upsampler temporary URL and storing it locally.
It does not serve downloads to customers (that is handled by the Download Manager). Instead, it handles the “internal” file persistence step after an Upsampler job completes.
Responsibilities
- Ensures there is a dedicated storage directory under WordPress uploads.
- Downloads files from Upsampler using streaming requests.
- Validates downloaded files are legitimate images and are an allowed MIME type.
- Stores the final file with a predictable, job-linked filename.
Storage Location
Files are stored under the WordPress uploads directory:
{uploads}/sell-my-images/
On first creation, the directory is protected by:
- a
.htaccessdenying direct access - an
index.php“silence is golden” file
Download + Validation Flow
Primary method:
SellMyImagesManagersFileManager::download_from_upsampler( $upscaled_url, $job_id )
Behavior:
- Streams the remote file to a temporary file on disk.
- Verifies the request returned HTTP 200.
- Validates content exists (file exists and size > 0).
- Confirms the file is a real image via
getimagesize(). - Verifies the MIME type is in the allowed list:
image/jpeg,image/jpg,image/png,image/webp
- Renames the temporary file to a final file with the correct extension.
Timeouts
Large image downloads use a longer HTTP timeout:
DOWNLOAD_TIMEOUT = 300seconds
Storage Stats
For admin/debug contexts, storage statistics can be retrieved via:
SellMyImagesManagersFileManager::get_storage_stats()
Returns:
file_counttotal_sizetotal_size_formatted
Related Code
sell-my-images/src/Managers/FileManager.phpsell-my-images/src/Managers/DownloadManager.php