Closed lijie-advantech closed 6 years ago
this test currently passes: ` @Test public void addAttachment() throws RedmineException, IOException { String attachmentContent = "some text"; File tempFile = createTempFile(attachmentContent);
final Issue issue = IssueFactory.create(projectId, "task with attachment");
final Issue createdIssue = issueManager.createIssue(issue);
attachmentManager.addAttachmentToIssue(createdIssue.getId(), tempFile, ContentType.TEXT_PLAIN.getMimeType());
try {
Issue loadedIssue = issueManager.getIssueById(createdIssue.getId(), Include.attachments);
final Collection<Attachment> attachments = loadedIssue.getAttachments();
Attachment next = attachments.iterator().next();
assertThat(next.getFileName()).isEqualTo(tempFile.getName());
final byte[] receivedContent = attachmentManager.downloadAttachmentContent(next);
String contentAsString = new String(receivedContent);
assertThat(contentAsString).isEqualTo(attachmentContent);
} finally {
issueManager.deleteIssue(createdIssue.getId());
}
}
`
with a dev Redmine install behind NGinx. feel free to provide a test case showing a problem, if it still exists. I will close this issue for now
File file = new File("D:\111.txt"); attachmentManager.addAttachmentToIssue(4031, file, ContentType.TEXT_PLAIN.getMimeType());
public String upload(InputStream content, long contentLength) throws RedmineException { ...... final String result = send(request); return parseResponse(result, "upload", input -> JsonInput.getStringNotNull(input, "token")); }