@Override public void consume(@Nonnull final Attachment attachment) { final InputStreamConsumer<Unit> streamConsumer = new InputStreamConsumer<Unit>() { @Override public Unit withInputStream(final InputStream inputStream) throws IOException { final String attachmentFileName = attachment.getFilename(); final ZipArchiveEntry zipEntry = new ZipArchiveEntry(uniqueFileNameGenerator.getUniqueFileName( attachmentFileName)); out.putArchiveEntry(zipEntry); IOUtil.copy(inputStream, out); out.closeArchiveEntry(); return Unit.UNIT; } }; try { attachmentManager.streamAttachmentContent(attachment, streamConsumer); } catch (final IOException e) { LOGGER.info("Streaming operation failed for attachment with Id " + attachment.getId()); } } };
try result = attachmentManager.streamAttachmentContent(attachment, new InputStreamConsumer<Boolean>()
final Attachment attachment = attachmentManager.getAttachment(attachmentId); attachmentManager.streamAttachmentContent(attachment, zipEntryStreamConsumer);
deleteQuietly(thumbnailFile); return attachmentManager.streamAttachmentContent(attachment, new InputStreamConsumer<Thumbnail>()
/** * @see AbstractViewFileServlet#getInputStream(String, com.atlassian.jira.util.io.InputStreamConsumer) */ protected void getInputStream(String attachmentQuery, InputStreamConsumer<Unit> consumer) throws PermissionException, IOException { Attachment attachment = getAttachment(attachmentQuery); if (!hasPermissionToViewAttachment(getUserName(), attachment)) { throw new PermissionException("You do not have permissions to view this issue"); } ComponentAccessor.getAttachmentManager().streamAttachmentContent(attachment, consumer); }
@Override public Either<NegativeResponseStatus, SuccessfulResponse> addAttachment(final String issueKey, final Attachment attachment) { try { final File attachmentFile = attachmentManager.streamAttachmentContent(attachment, new InputStreamConsumer<File>() { @Override public File withInputStream(final InputStream inputStream) throws IOException {