Generic Package Registry: downloading files from release page doesn't respect file name
Context
In Avoid copy operation in object store during Gen... (!147454 - merged), we made a change to the way the packages are uploaded to the Generic Package Repository: Instead of uploading the file to a temp location on the Object Storage, and then make a copy operation to move the file to its final location, we now upload the file to its final location directly.
This caused a bit of a side effect: the file now is uploaded and resides on the Object Storage without its file name. So when we download the file, we rely on rails to attach the correct file name to the download response so that the browser respects this name and download the file with its correct name.
This part in the codebase is responsible for attaching the name to the download response when a package is downloaded from the UI.
The generic packages can be used in the project's release feature. On the release page, the generic packages can be referenced for download. However, the download URL for those packages are different from the one used for download in the package registry:
- Download URL in the package registry:
https://gitlab.com/<group>/<project>/-/package_files/<package_file_id>/download
- Download URL in the release page:
https://gitlab.com/api/v4/projects/<project_id>/packages/generic/<package_name>/<package_version>/<package_file_name>
As we can see, the release page is trying to download the package using an API endpoint, and because of that, the download URL on the release page doesn't follow the same code path that the package registry URLs follow, and this resulted in not attaching the file name to the download response.
However, this bug doesn't occur on gitlab.com, it only occurs on the self-managed instances that use aws as an Object Storage. The part in the codebase that handles the download response is missing the params that should attach the file name to the download response.
Solution
Add redirect_params
to the URL that we generate here. It should be similar to what we do here.