move($tmpDir, $file->getClientOriginalName()); $result = $this->scanner->setFile($tmpFile) ->scan(ScanConfiguration::make( owner: $uploader, makePublic: $uploader->preferences->makeUploadsPublic )); throw_if($result->isError(), new SongUploadFailedException($result->error)); return $result; } public function copyToLocal(Song $song): string { $tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'koel_tmp'; File::ensureDirectoryExists($tmpDir); $publicUrl = $this->getSongPresignedUrl($song); $localPath = $tmpDir . DIRECTORY_SEPARATOR . basename($song->storage_metadata->getPath()); File::copy($publicUrl, $localPath); return $localPath; } protected function generateStorageKey(string $filename, User $uploader): string { return sprintf('%s__%s__%s', $uploader->id, Str::lower(Ulid::generate()), $filename); } abstract public function getSongPresignedUrl(Song $song): string; }