Patch #19116
closedFiles REST API
Added by Lucile Quirion over 9 years ago. Updated over 7 years ago.
0%
Description
Context:
To integrate Redmine with our CI tool (Jenkins), I need to be able to upload files via the REST API.
This patch add the Files REST API for:
- getting the list of files for a project and its versions.
- creating new files from uploaded attachments.
Apply on svn revision r14015
Formatted with git
Related Issues: #7725, #18245 and #13800
Files
0001-REST-API-add-files-REST-API.patch (9.41 KB) 0001-REST-API-add-files-REST-API.patch | Lucile Quirion, 2015-02-16 20:21 | ||
0001-REST-API-add-files-REST-API_v2.patch (9.43 KB) 0001-REST-API-add-files-REST-API_v2.patch | Lucile Quirion, 2015-02-19 17:07 | ||
0001-REST-API-add-files-REST-API_v3.patch (8.48 KB) 0001-REST-API-add-files-REST-API_v3.patch | Jake Kemme, 2016-07-22 19:07 |
Related issues
Updated by Lucile Quirion over 9 years ago
- Description updated (diff)
- Status changed from New to Needs feedback
Updated by Jean-Philippe Lang over 9 years ago
- Assignee set to Lucile Quirion
That's a good start but here are a few things that need to be changed:
- I'll prefer to keep only one resource for project files, which would be
/projects/:project_id/files
, so we should remove the alternatePOST /projects/foo/versions/123/files
to create a file associated to a version (POST /projects/foo/files
with a version_id attribute will be used instead).
POST /projects/:project_id/files
should create a single file with the file attributes given in a "file" hash (instead ofattachments / file_1
), eg.
{ "file": { "filename": "foo", ... }
GET /projects/:project_id/files
should include the names of author and version (if any), just like it's done for the issues, eg.:api.author(:id => file.author_id, :name => file.author.name)
- Maybe should simply use the AttachmentsHelper#render_api_attachment to format most of the file attributes
- We don't keep track of authors in the source code
- I hold the copyright for the Redmine source code, I can't include a source file that is copyrighted to a third-party in the core.
Updated by Lucile Quirion over 9 years ago
Thanks for the feedback, I'll modify my patch.
Concerning the POST request, would the following JSON be acceptable ?
{ "project": { "version_id": "123", "files": [ { "filename": "file_1", "description": "", "content_type": "", "token": "foo_1" }, { "filename": "file_2", "token": "foo_2" } ] } }
Where version_id, filename, description and content_type are optional parameters.
This way it will be possible to handle several files at once (as done in the IssuesController).
Updated by Lucile Quirion over 9 years ago
Here is the updated patch.
The expected JSON format is
{ "file": { "filename", ... } }
I used the AttachmentsHelper#render_api_attachment, which I've modified to accept additional options (in order to diplay the version_id).
I can remove this modification if necessary.
Updated by Lucile Quirion over 9 years ago
- Assignee changed from Lucile Quirion to Jean-Philippe Lang
Updated by Toshi MARUYAMA over 9 years ago
- Related to Feature #7725: REST API for files added
Updated by Toshi MARUYAMA over 9 years ago
- Related to Feature #18245: Documents REST API added
Updated by Toshi MARUYAMA over 9 years ago
- Related to Feature #13800: File REST API added
Updated by Marco Descher almost 9 years ago
Any chance this will be part of an upcoming release? :)
Updated by Larry Owen over 8 years ago
What's the status on this feature? Sure would be helpful.
Updated by Go MAEDA over 8 years ago
The patch 0001-REST-API-add-files-REST-API_v2.patch cannot be applied to current trunk (r15012).
$ patch -p1 < 0001-REST-API-add-files-REST-API_v2.patch patching file app/controllers/files_controller.rb Hunk #3 FAILED at 49. 1 out of 3 hunks FAILED -- saving rejects to file app/controllers/files_controller.rb.rej patching file app/helpers/attachments_helper.rb patching file app/views/files/index.api.rsb patching file test/integration/api_test/api_routing_test.rb patching file test/integration/api_test/files_test.rb
Updated by Jake Kemme about 8 years ago
Updated Patch from Hg attached. We are currently using on 3.3 with no issues.
Updated by Toshi MARUYAMA almost 8 years ago
- Status changed from Needs feedback to New
- Target version set to 3.4.0
Updated by Jean-Philippe Lang over 7 years ago
- Status changed from New to Closed
Committed in r16109 with a few changes to the index response. Thanks.