storeFile->create( uploader: $user, originalName: basename($path), path: $path, mimeType: $disk->mimeType($path) ?: 'application/octet-stream', size: $disk->size($path), checksum: $this->checksumOf($disk, $path), folderId: null, disk: $diskName, action: Action::FileImported, ); } /** * Streamed rather than hash_file() on a local path — the only way to * checksum a file that might live on a non-local disk (S3 has no * local filesystem path to hand hash_file()). */ private function checksumOf(Filesystem $disk, string $path): string { $stream = $disk->readStream($path); if ($stream === null) { return ''; } $context = hash_init('sha256'); hash_update_stream($context, $stream); fclose($stream); return hash_final($context); } }