public class AttachmentResource extends Object
Modifier and Type | Class and Description |
---|---|
static class |
AttachmentResource.ConfluenceAttachmentMultipartConfig |
Constructor and Description |
---|
AttachmentResource(AttachmentService attachmentService) |
Modifier and Type | Method and Description |
---|---|
RestList<Content> |
createAttachments(ContentId contentId,
List<com.atlassian.plugins.rest.common.multipart.FilePart> fileParts,
List<com.atlassian.plugins.rest.common.multipart.FilePart> comments,
List<com.atlassian.plugins.rest.common.multipart.FilePart> minorEdits)
Add one or more attachments to a Confluence Content entity, with optional comments.
|
RestList<Content> |
getAttachments(ContentId contentId,
String expand,
int start,
int limit,
String filename,
String mediaType,
javax.ws.rs.core.UriInfo uriInfo)
Returns a paginated list of attachment Content entities within a single container.
|
Content |
update(String attachmentId,
Content attachment)
Update the non-binary data of an Attachment.
|
Content |
updateData(ContentId attachmentId,
com.atlassian.plugins.rest.common.multipart.FilePart filePart,
com.atlassian.plugins.rest.common.multipart.FilePart comment,
com.atlassian.plugins.rest.common.multipart.FilePart minorEdit)
Update the binary data of an Attachment, and optionally the comment and the minor edit field.
|
public AttachmentResource(AttachmentService attachmentService)
@PublicApi public RestList<Content> getAttachments(ContentId contentId, String expand, int start, int limit, String filename, String mediaType, @Context javax.ws.rs.core.UriInfo uriInfo) throws ServiceException
Returns a paginated list of attachment Content entities within a single container.
Example request URI(s):
http://example.com/rest/api/content/1234/child/attachment?start=0&limit=10
http://example.com/rest/api/content/1234/child/attachment?filename=myfile.txt&expand=version,container
contentId
- a string containing the id of the attachments content containerexpand
- a comma separated list of properties to expand on the Attachments returned. Optional.start
- the index of the first item within the result set that should be returned. Optional.limit
- how many items should be returned after the start index. Optional.filename
- (optional) filter parameter to return only the Attachment with the matching file name. Optional.mediaType
- (optional) filter parameter to return only Attachments with a matching Media-Type. Optional.uriInfo
- (injected) information about the request URIServiceException
@PublicApi public RestList<Content> createAttachments(ContentId contentId, List<com.atlassian.plugins.rest.common.multipart.FilePart> fileParts, @Nullable List<com.atlassian.plugins.rest.common.multipart.FilePart> comments, @Nullable List<com.atlassian.plugins.rest.common.multipart.FilePart> minorEdits) throws ServiceException
Add one or more attachments to a Confluence Content entity, with optional comments.
Comments are optional, but if included there must be as many comments as there are files, and the comments must be in the same order as the files.
This resource expects a multipart post. The media-type multipart/form-data is defined in RFC 1867. Most client libraries have classes that make dealing with multipart posts simple. For instance, in Java the Apache HTTP Components library provides a MultiPartEntity that makes it simple to submit a multipart POST.
In order to protect against XSRF attacks, because this method accepts multipart/form-data, it has XSRF protection on it. This means you must submit a header of X-Atlassian-Token: nocheck with the request, otherwise it will be blocked.
The name of the multipart/form-data parameter that contains attachments must be "file"
A simple example to attach a file called "myfile.txt" to the container with id "123", with a comment included:
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "comment=This is my File" http://myhost/rest/api/content/123/child/attachment
A example to attach a file called "myfile.txt" to the container with id "123", with a comment, and set the minorEdits flag to be true:
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "minorEdit=true" -F "comment=This is my File" http://myhost/rest/api/content/123/child/attachment
An example to attach the same file, with no comment:
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" http://myhost/rest/api/content/123/child/attachment
Example request URI(s):
http://example.com/rest/api/content/1234/child/attachment
contentId
- a string containing the id of the attachments content containerfileParts
- a list of fileparts containing the data for each attachment to be createdcomments
- (optional) a list of comments matching the list of attachment data. If supplied, the size of this
list must match the size of the fileParts listminorEdits
- (optional) form parameter indicating whether the attachments should be minorEdits.
If minorEdits is set to true, no notification email or activity stream will be generated for that attachment.ServiceException
@PublicApi public Content update(String attachmentId, Content attachment) throws ServiceException
Update the non-binary data of an Attachment.
This resource can be used to update an attachment's filename, media-type, comment, and parent container.
Example request URI(s):
http://example.com/rest/api/content/1234/child/attachment/5678
attachmentId
- the id of the attachment to updateattachment
- the details of the Attachment to be updatedServiceException
@PublicApi public Content updateData(ContentId attachmentId, com.atlassian.plugins.rest.common.multipart.FilePart filePart, com.atlassian.plugins.rest.common.multipart.FilePart comment, com.atlassian.plugins.rest.common.multipart.FilePart minorEdit) throws ServiceException
Update the binary data of an Attachment, and optionally the comment and the minor edit field.
This adds a new version of the attachment, containing the new binary data, filename, and content-type.
When updating the binary data of an attachment, the comment related to it together with the field that specifies if it's a minor edit can be updated as well, but are not required. If an update is considered to be a minor edit, notifications will not be sent to the watchers of that content.
This resource expects a multipart post. The media-type multipart/form-data is defined in RFC 1867. Most client libraries have classes that make dealing with multipart posts simple. For instance, in Java the Apache HTTP Components library provides a MultiPartEntity that makes it simple to submit a multipart POST.
In order to protect against XSRF attacks, because this method accepts multipart/form-data, it has XSRF protection on it. This means you must submit a header of X-Atlassian-Token: nocheck with the request, otherwise it will be blocked.
The name of the multipart/form-data parameter that contains attachments must be "file"
A simple example to upload a file called "myfile.txt" to the Attachment with id "456" in a container with id "123", with the comment updated, and minorEdit set to true:
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "minorEdit=true" -F "comment=This is my updated File" http://myhost/rest/api/content/123/child/attachment/456/data
An example to upload the same file, with no comment:
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" http://myhost/rest/api/content/123/child/attachment/456/data
Example request URI(s):
http://example.com/rest/api/content/1234/child/attachment/5678/data
attachmentId
- the id of the attachment to upload a new file forfilePart
- the file to be uploadedminorEdit
- (optional) form parameter indicating whether the attachment should be a minorEdit.
If minorEdit is set to true, no notification email or activity stream will be generated for that attachment.comment
- the comment to associate with the attachment - may be a blank stringServiceException
Copyright © 2003–2016 Atlassian. All rights reserved.