public NotificationRef createAttachment(CreateAttachment create) { CouchMediaType mediaType = CouchMediaType.fromString(create.getContentType()); NotificationRef notificationRef = create.getNotificationRef(); WriteResponse response = couchDatabase.put().attachment( notificationRef.getNotificationId(), notificationRef.getRevision(), create.getAttachmentName(), mediaType, create.getInputStream()) .onError(r -> throwError(r, format("Failure storing notification attachment in couch [%s] - %s", r.getHttpStatus(), r.getErrorReason()))) .execute(); return new NotificationRef(notificationRef.getDomainName(), notificationRef.getNotificationId(), response.getDocumentRevision()); }