{"record":{"id":"1e9fe1422d195b3d","repo":"octobercms/october","slug":"error-saving-remote-file-to-a-temporary-location","errorCode":null,"errorMessage":"Error saving remote file to a temporary location","messagePattern":"Error saving remote file to a temporary location","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/media/widgets/MediaManager.php","lineNumber":1398,"sourceCode":"                if (!is_numeric($width) || !is_numeric($height) || !is_numeric($lastModified)) {\n                    throw new ApplicationException('Invalid input data');\n                }\n\n                if (!$thumbnailParams) {\n                    $thumbnailParams = $this->getThumbnailParams();\n                    $thumbnailParams['width'] = $width;\n                    $thumbnailParams['height'] = $height;\n                }\n\n                $thumbnailPath = $this->getThumbnailImagePath($thumbnailParams, $path, $lastModified);\n                $fullThumbnailPath = temp_path(ltrim($thumbnailPath, '/'));\n\n                // Save the file locally\n                $library = MediaLibrary::instance();\n                $tempFilePath = $this->getLocalTempFilePath($path);\n\n                if (!@File::put($tempFilePath, $library->get($path))) {\n                    throw new SystemException('Error saving remote file to a temporary location');\n                }\n\n                // Resize the thumbnail and save to the thumbnails directory\n                $this->resizeImage($fullThumbnailPath, $thumbnailParams, $tempFilePath);\n\n                // Delete the temporary file\n                File::delete($tempFilePath);\n                $markup = $this->makePartial('thumbnail-image', [\n                    'isError' => false,\n                    'imageUrl' => $this->getThumbnailImageUrl($thumbnailPath)\n                ]);\n            }\n        }\n        catch (Exception $ex) {\n            if ($tempFilePath) {\n                File::delete($tempFilePath);\n            }\n","sourceCodeStart":1380,"sourceCodeEnd":1416,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/media/widgets/MediaManager.php#L1380-L1416","documentation":"SystemException thrown at MediaManager.php:1398 when File::put() fails while copying the original file from the media library disk (MediaLibrary::get($path)) into a local temp file for thumbnail generation. The @ operator suppresses the PHP warning, so this exception is often the first visible symptom of an unreadable media disk or unwritable temp directory.","triggerScenarios":"onGenerateThumbnail for an image whose bytes cannot be fetched (S3/media disk credentials wrong, bucket unreachable, R2 adapter misconfigured) or cannot be written to the path returned by getLocalTempFilePath() (temp_path()/public not writable, disk full, open_basedir restriction).","commonSituations":"Wrong values in config/filesystems.php for the 'media' disk (missing key/secret/region); storage directory permissions after a server move or Docker volume mount; disk full on the temp partition; safe_mode/open_basedir blocking the temp path.","solutions":["Verify the media disk reads work: check filesystems.disks.media credentials and run a test MediaLibrary::get() in tinker for the failing path.","Check the web server user can write to the directory returned by temp_path() (e.g. storage/app/temp or sys_get_temp_dir) — fix with chown/chmod.","Check df -h for a full temp disk and php.ini open_basedir for path exclusions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Server-side smoke check before heavy use\n$disk = Storage::disk(Config::get('cms.storage.media.disk', 'media'));\nif (!$disk->has($path)) {\n    throw new RuntimeException('Media item missing on disk: ' . $path);\n}","typeGuard":null,"tryCatchPattern":"try {\n    $widget->onGenerateThumbnail();\n} catch (\\System\\Classes\\SystemException $e) {\n    \\Log::warning('Thumbnail generation failed: ' . $e->getMessage());\n    // degrade gracefully: serve the original URL instead of a thumbnail\n}","preventionTips":["Health-check the media disk (list + read one object) in deploy pipelines.","Monitor free space on the temp volume.","Run PHP under a user that owns the temp directory."],"tags":["media-manager","thumbnails","filesystem","s3","permissions","disk-full"],"backgroundTag":"file-write-failed","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}