User File Attachment List Resource¶
Added in 3.0
A resource representing a file attachment owned by a user.
The file attachment is not tied to any particular review request, and instead is owned by a user for usage in Markdown-formatted text.
The file contents are optional when first creating a file attachment. This is to allow a caller to create the attachment and get the resulting URL for embedding in a text field. The file’s contents can then be added separately (and only once) in a PUT request.
Details¶
Name | user_file_attachments |
URI | /api/users/{username}/user-file-attachments/ |
Token Policy ID | user_file_attachment |
HTTP Methods | |
Parent Resource | |
Child Resources |
Links¶
Name |
Method |
Resource |
---|---|---|
create | POST |
|
self | GET |
HTTP GET¶
Returns a list of file attachments that are owned by the user.
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 that is owned by the user.
This accepts any file type and associates it with the user. Optionally, the file may be omitted here and uploaded later by updating the file attachment.
If file data is provided, then it is expected that the data will be
encoded as multipart/form-data. 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 --
Extra data can be stored for later lookup. See Storing/Accessing Extra Data for more information.
Request Parameters¶
captionString | The optional caption describing the file. |
pathUploaded file | The file to upload. |
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.user-file-attachments+json¶
$ curl https://reviews.example.com/api/users/admin/user-file-attachments/ -H "Accept: application/json"
HTTP 200 OK
Content-Length: 1011
Content-Type: application/vnd.reviewboard.org.user-file-attachments+json
ETag: 0d51d06be6151646c371e31b818c9c0c1068a754
Item-Content-Type: application/vnd.reviewboard.org.user-file-attachment+json
Vary: Accept, Cookie
X-Content-Type-Options: nosniff
{
"links": {
"create": {
"href": "https://reviews.example.com/api/users/admin/user-file-attachments/",
"method": "POST"
},
"self": {
"href": "https://reviews.example.com/api/users/admin/user-file-attachments/",
"method": "GET"
}
},
"stat": "ok",
"total_results": 1,
"user_file_attachments": [
{
"absolute_url": "http://example.com/users/admin/file-attachments/5ecb375b-4819-4f6e-b8cf-b4d603d3dfd7/",
"caption": "Mockup",
"extra_data": {},
"filename": "mockup.png",
"icon_url": "/static/rb/images/mimetypes/text-x-generic.png",
"id": 5,
"links": {
"delete": {
"href": "https://reviews.example.com/api/users/admin/user-file-attachments/5/",
"method": "DELETE"
},
"self": {
"href": "https://reviews.example.com/api/users/admin/user-file-attachments/5/",
"method": "GET"
},
"update": {
"href": "https://reviews.example.com/api/users/admin/user-file-attachments/5/",
"method": "PUT"
}
},
"mimetype": "image/png",
"thumbnail": "<div class=\"file-thumbnail\"> <img src=\"\" srcset=\" 1x, 2x\" alt=\"Mockup\" width=\"300\" /></div>"
}
]
}