Skip to content

Support path parameter for repository download via API

What does this MR do and why?

This MR adds another parameter to the repository download API (GET /projects/:id/repository/archive[.format]), path. Using path you can restrict the download to only a subfolder of the repository. This is symmetric to the already existing UI feature. Therefore, the implementation was quite easy.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Find the project id with at least one subfolder
  2. Call or open https://<GITLAB-URL>/api/v4/projects/<project-id>/repository/archive?path=<subfolder-path> (use authentication as needed)
  3. The HTTP result will have the Content-Type: application/octet-stream header and therefore trigger the download of a tar.gz file
  4. Inside the archive file only the folder given step 2 will be present

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #28827 (closed)

Merge request reports