Skip to content

Retrieve uploaded files using API

Problem to solve

It's possible to upload a file using the api (POST /api/v4/:project_id/uploads) but there is no way to retrieve the uploaded files (it used to be possible using the Private-Token auth and the web route /:namespace_id/:project_id/uploads/:secret/:file_name)

Edit by @Andysoiron: It seems to be still possible to retrieve the file using /:namespace_id/:project_id/uploads/:secret/:file_name #25838 (comment 272514463).

Target audience

API users that want to retrieve uploaded files.

Proposal

Add support to the REST API for retrieving a list of project uploads, downloading a specific uploaded file, and deleting an individual file.

Example Use Case

Add a new field to the response of POST /projects/:id/uploads to return the full path to the file including the project path.

Example:

{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "full_url": "/namespace123/project321/66dbcd21ec5d24ed6ea225176098d52b/dk.png"
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}

Acceptance

I can call the REST API to:

  • Retrieve a paginated list of all uploads to a specific namespace.
  • Download a specific uploaded file within a namespace.
  • Delete an individual uploaded file.

Issue Resolved details

API links for finding and managing uploads are here (thanks Heinrich)!:

Edited by Alvin Gounder