File Attachment List Resource¶
Added in 1.6
A resource representing a file attachment on a review request.
Details¶
Name | file_attachments |
URI | /api/review-requests/{review_request_id}/file-attachments/ |
Token Policy ID | file_attachment |
HTTP Methods | |
Parent Resource | |
Child Resources |
Links¶
Name |
Method |
Resource |
---|---|---|
create | POST |
|
self | GET |
HTTP GET¶
Returns a list of file attachments on the review request.
Each item in this list is a file attachment attachment that is shown on the review request.
Request Parameters¶
counts-onlyBoolean | If specified, a single |
max-resultsInteger | The maximum number of results to return in this list. By default, this is 25. There is a hard limit of 200; if you need more than 200 results, you will need to make more than one request, using the “next” pagination link. |
startInteger | The 0-based index of the first result in the list. The start index is usually the previous start index plus the number of previous results. By default, this is 0. |
Errors¶
100 - Does Not ExistHTTP 404 - Not Found | Object does not exist |
101 - Permission DeniedHTTP 403 - Forbidden | You don’t have permission for this |
103 - Not Logged InHTTP 401 - Unauthorized | You are not logged in |
105 - Invalid Form DataHTTP 400 - Bad Request | One or more fields had errors |
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden | Your OAuth2 token lacks the necessary scopes for this request. |
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden | OAuth2 token access for this resource is prohibited. |
HTTP POST¶
Creates a new file attachment from a file attachment.
This accepts any file type and associates it with a draft of a review request.
Creating a new file attachment will automatically create a new review request draft, if one doesn’t already exist. This attachment will be part of that draft, and will be shown on the review request when it’s next published.
It is expected that the client will send the data as part of a
multipart/form-data mimetype. The file’s name
and content should be stored in the path
field. A typical request
may look like:
-- SoMe BoUnDaRy
Content-Disposition: form-data; name=path; filename="foo.zip"
<Content here>
-- SoMe BoUnDaRy --
Request Parameters¶
pathUploaded file | Required The file to upload. |
attachment_historyInteger | ID of the corresponding FileAttachmentHistory. Added in 2.5 |
captionString | The optional caption describing the file. |
Errors¶
100 - Does Not ExistHTTP 404 - Not Found | Object does not exist |
101 - Permission DeniedHTTP 403 - Forbidden | You don’t have permission for this |
103 - Not Logged InHTTP 401 - Unauthorized | You are not logged in |
105 - Invalid Form DataHTTP 400 - Bad Request | One or more fields had errors |
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden | Your OAuth2 token lacks the necessary scopes for this request. |
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden | OAuth2 token access for this resource is prohibited. |
Examples¶
application/vnd.reviewboard.org.file-attachments+json¶
$ curl https://reviews.example.com/api/review-requests/8/file-attachments/ -H "Accept: application/json"
HTTP 200 OK
Content-Length: 1574
Content-Type: application/vnd.reviewboard.org.file-attachments+json
ETag: b87255a2a4e14b6ef4da1d35fe2aab4a48870ea7
Item-Content-Type: application/vnd.reviewboard.org.file-attachment+json
Vary: Accept, Cookie
X-Content-Type-Options: nosniff
{
"file_attachments": [
{
"absolute_url": "http://example.com/r/8/file/1/download/",
"attachment_history_id": null,
"caption": "Example Attachment",
"extra_data": {},
"filename": "screenshot1.png",
"icon_url": "/static/rb/images/mimetypes/text-x-generic.png",
"id": 1,
"is_review_ui_accessible_by": true,
"links": {
"delete": {
"href": "https://reviews.example.com/api/review-requests/8/file-attachments/1/",
"method": "DELETE"
},
"file_attachment_comments": {
"href": "https://reviews.example.com/api/review-requests/8/file-attachments/1/file-attachment-comments/",
"method": "GET"
},
"self": {
"href": "https://reviews.example.com/api/review-requests/8/file-attachments/1/",
"method": "GET"
},
"update": {
"href": "https://reviews.example.com/api/review-requests/8/file-attachments/1/",
"method": "PUT"
}
},
"mimetype": "image/png",
"review_url": "/r/8/file/1/",
"revision": 0,
"thumbnail": "<div class=\"file-thumbnail\"> <img src=\"http://example.com/r/8/file/1/download/?thumbnail=1&width=300\" srcset=\"http://example.com/r/8/file/1/download/?thumbnail=1&width=300 1x, http://example.com/r/8/file/1/download/?thumbnail=1&width=600 2x, http://example.com/r/8/file/1/download/?thumbnail=1&width=900 3x\" alt=\"Example Attachment\" width=\"300\" /></div>",
"url": "http://example.com/r/8/file/1/download/"
}
],
"links": {
"create": {
"href": "https://reviews.example.com/api/review-requests/8/file-attachments/",
"method": "POST"
},
"self": {
"href": "https://reviews.example.com/api/review-requests/8/file-attachments/",
"method": "GET"
}
},
"stat": "ok",
"total_results": 1
}