User File Attachment 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_attachment |
URI | /api/users/{username}/user-file-attachments/{file_attachment_id}/ |
Token Policy ID | user_file_attachment |
HTTP Methods | |
Parent Resource | |
Child Resources | None |
Fields¶
absolute_urlString | The absolute URL of the file, for downloading purposes. Added in 2.0 |
captionString | The file’s descriptive caption. |
extra_dataDictionary | Extra data as part of the file attachment. This can be set by the API or extensions. Added in 6.0 |
filenameString | The name of the file. |
icon_urlString | Deprecated The URL to a 24x24 icon representing this file. The use of these icons is deprecated and this property will be removed in a future version. Deprecated in 2.5 |
idInteger | The numeric ID of the file. |
mimetypeString | The mimetype for the file. Added in 2.0 |
thumbnailString | A thumbnail representing this file. Added in 1.7 |
Links¶
Name |
Method |
Resource |
---|---|---|
delete | DELETE |
|
self | GET |
|
update | PUT |
HTTP DELETE¶
Deletes a file attachment.
This will permanently remove the file attachment owned by the user. This cannot be undone.
The file attachment can only be deleted by its owner or an administrator.
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 |
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 GET¶
Returns information on a user’s file attachment.
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 |
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 PUT¶
Updates the file attachment’s data.
This allows updating information on the file attachment. It also allows the file to be uploaded if this was not done when the file attachment was created.
The file attachment’s file cannot be updated once it has been uploaded. Attempting to update the file attachment’s file if it has already been uploaded will result in a 111 - Duplicate Item.
The file attachment can only be updated by its owner or by an administrator.
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¶
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 |
111 - Duplicate ItemHTTP 409 - Conflict | An entry for this item or its unique key(s) already exists |
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-attachment+json¶
$ curl https://reviews.example.com/api/users/admin/user-file-attachments/5/ -H "Accept: application/json"
HTTP 200 OK
Content-Length: 1213
Content-Type: application/vnd.reviewboard.org.user-file-attachment+json
ETag: ccf4f8704ad37d437a4c5d11cf2a7fac73c40333
Vary: Accept, Cookie
X-Content-Type-Options: nosniff
{
"stat": "ok",
"user_file_attachment": {
"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=\"http://example.com/users/admin/file-attachments/5ecb375b-4819-4f6e-b8cf-b4d603d3dfd7/?thumbnail=1&width=300\" srcset=\"http://example.com/users/admin/file-attachments/5ecb375b-4819-4f6e-b8cf-b4d603d3dfd7/?thumbnail=1&width=300 1x, http://example.com/users/admin/file-attachments/5ecb375b-4819-4f6e-b8cf-b4d603d3dfd7/?thumbnail=1&width=600 2x, http://example.com/users/admin/file-attachments/5ecb375b-4819-4f6e-b8cf-b4d603d3dfd7/?thumbnail=1&width=900 3x\" alt=\"Mockup\" width=\"300\" /></div>"
}
}