Jump to >

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
  • GET - Returns a list of file attachments that are owned by the user.
  • POST - Creates a new file attachment that is owned by the user.
Parent Resource User Resource
Child Resources
Anonymous Access Yes, if anonymous site access is enabled

HTTP GET

Returns a list of file attachments that are owned by the user.

Request Parameters

counts-onlyBoolean If specified, a single count field is returned with the number of results, instead of the results themselves.
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 --

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 http://reviews.example.com/apiadmin/ -H "Accept: application/json"
Vary: Accept, Cookie
Item-Content-Type: application/vnd.reviewboard.org.user-file-attachment+json
Content-Type: application/vnd.reviewboard.org.user-file-attachments+json
ETag: d18b64221e63779fe64cf1213248f446466393a9
X-Content-Type-Options: nosniff
{
  "links": {
    "create": {
      "href": "http://reviews.example.com/apiadmin/", 
      "method": "POST"
    }, 
    "self": {
      "href": "http://reviews.example.com/apiadmin/", 
      "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", 
      "filename": "mockup.png", 
      "icon_url": "/static/rb/images/mimetypes/text-x-generic.png", 
      "id": 5, 
      "links": {
        "delete": {
          "href": "http://reviews.example.com/api/users/admin/user-file-attachments/5/", 
          "method": "DELETE"
        }, 
        "self": {
          "href": "http://reviews.example.com/api/users/admin/user-file-attachments/5/", 
          "method": "GET"
        }, 
        "update": {
          "href": "http://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>"
    }
  ]
}