public class AttachmentManager
extends java.lang.Object
Obtain it via RedmineManager:
RedmineManager redmineManager = RedmineManagerFactory.createWithUserAuth(redmineURI, login, password); AttachmentManager attachmentManager = redmineManager.getAttachmentManager();
Sample usage:
File file = ... attachmentManager.addAttachmentToIssue(issueId, file, ContentType.TEXT_PLAIN.getMimeType());
Modifier and Type | Method and Description |
---|---|
Attachment |
addAttachmentToIssue(java.lang.Integer issueId,
java.io.File attachmentFile,
java.lang.String contentType) |
byte[] |
downloadAttachmentContent(Attachment issueAttachment)
Downloads the content of an
Attachment from the Redmine server. |
void |
downloadAttachmentContent(Attachment issueAttachment,
java.io.OutputStream stream) |
Attachment |
getAttachmentById(int attachmentID)
Delivers an
Attachment by its ID. |
Attachment |
uploadAttachment(java.lang.String contentType,
java.io.File content)
Uploads an attachment.
|
Attachment |
uploadAttachment(java.lang.String fileName,
java.lang.String contentType,
byte[] content)
Uploads an attachment.
|
Attachment |
uploadAttachment(java.lang.String fileName,
java.lang.String contentType,
java.io.InputStream content)
Uploads an attachment.
|
public Attachment addAttachmentToIssue(java.lang.Integer issueId, java.io.File attachmentFile, java.lang.String contentType) throws RedmineException, java.io.IOException
issueId
- database ID of the IssueattachmentFile
- the file to uploadcontentType
- MIME type. depending on this parameter, the file will be recognized by the server as
text or image or binary. see http://en.wikipedia.org/wiki/Internet_media_type for possible MIME types.
sample value: ContentType.TEXT_PLAIN.getMimeType()RedmineException
java.io.IOException
public Attachment uploadAttachment(java.lang.String fileName, java.lang.String contentType, byte[] content) throws RedmineException, java.io.IOException
fileName
- file name of the attachment.contentType
- content type of the attachment.content
- attachment content stream.RedmineException
- if something goes wrong.java.io.IOException
- if input cannot be read.public Attachment uploadAttachment(java.lang.String contentType, java.io.File content) throws RedmineException, java.io.IOException
contentType
- content type of the attachment.content
- attachment content stream.RedmineException
- if something goes wrong.java.io.IOException
- if input cannot be read.public Attachment uploadAttachment(java.lang.String fileName, java.lang.String contentType, java.io.InputStream content) throws RedmineException, java.io.IOException
fileName
- file name of the attachment.contentType
- content type of the attachment.content
- attachment content stream.RedmineException
- if something goes wrong.java.io.IOException
- if input cannot be read. This exception cannot be thrown yet
(I am not sure if http client can distinguish "network"
errors and local errors) but is will be good to distinguish
reading errors and transport errors.public Attachment getAttachmentById(int attachmentID) throws RedmineException
Attachment
by its ID.attachmentID
- the IDAttachment
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be foundpublic void downloadAttachmentContent(Attachment issueAttachment, java.io.OutputStream stream) throws RedmineException
RedmineException
public byte[] downloadAttachmentContent(Attachment issueAttachment) throws RedmineException
Attachment
from the Redmine server.issueAttachment
- the Attachment
RedmineCommunicationException
- thrown in case the download failsRedmineException