Files
fotospiel-app/app/Support/UploadStream.php
Codex Agent 3e9f09571b
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Stream tenant uploads
2026-01-02 20:51:52 +01:00

35 lines
756 B
PHP

<?php
namespace App\Support;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
class UploadStream
{
/**
* Store an uploaded file without loading it fully into memory.
*/
public static function putUploadedFile(string $disk, string $path, UploadedFile $file): bool
{
$sourcePath = $file->getRealPath() ?: $file->getPathname();
if (! $sourcePath) {
return false;
}
$stream = fopen($sourcePath, 'rb');
if (! $stream) {
return false;
}
try {
return Storage::disk($disk)->put($path, $stream);
} finally {
if (is_resource($stream)) {
fclose($stream);
}
}
}
}