Patch #19116
closedFiles REST API
Added by Lucile Quirion almost 12 years ago. Updated almost 10 years ago.
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 |
Updated by Lucile Quirion almost 12 years ago
Actions
#1
- Category set to REST API
Updated by Lucile Quirion almost 12 years ago
Actions
#2
- Description updated (diff)
- Status changed from New to Needs feedback
Updated by Jean-Philippe Lang almost 12 years ago
Actions
#3
- 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/filesto create a file associated to a version (POST /projects/foo/fileswith a version_id attribute will be used instead).
POST /projects/:project_id/filesshould create a single file with the file attributes given in a "file" hash (instead ofattachments / file_1), eg.
GET /projects/:project_id/filesshould 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 almost 12 years ago
Actions
#4
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 almost 12 years ago
Actions
#5
Updated by Lucile Quirion almost 12 years ago
Actions
#6
- Assignee changed from Lucile Quirion to Jean-Philippe Lang
Updated by Toshi MARUYAMA over 11 years ago
Actions
#7
- Related to Feature #7725: REST API for files added
Updated by Toshi MARUYAMA over 11 years ago
Actions
#8
- Related to Feature #18245: Documents REST API added
Updated by Toshi MARUYAMA over 11 years ago
Actions
#9
- Related to Feature #13800: File REST API added
Updated by Marco Descher about 11 years ago
Actions
#10
Any chance this will be part of an upcoming release? :)
Updated by Larry Owen almost 11 years ago
Actions
#11
What's the status on this feature? Sure would be helpful.
Updated by Go MAEDA almost 11 years ago
Actions
#12
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 over 10 years ago
Actions
#13
Updated Patch from Hg attached. We are currently using on 3.3 with no issues.
Updated by Toshi MARUYAMA over 10 years ago
Actions
#14
- Status changed from Needs feedback to New
- Target version set to 3.4.0
Updated by Jean-Philippe Lang almost 10 years ago
Actions
#15
- Status changed from New to Closed
Committed in r16109 with a few changes to the index response. Thanks.