helun/Ektorp — Issue #57: Fetch attachments from previous revisions
Author: martincastell
Created: 2011-11-01 02:20:53+00:00
State: open

It is possible to fetch attachments from previous revisions in couchdb:
http://localhost:5984/dbName/docId/attachmentName?rev=revisionId

It would be nice to have an overloaded version of the getAttachment method, something like:

public AttachmentInputStream getAttachment(final String id, final String attachmentId, final String rev) {
assertDocIdHasValue(id);
Assert.hasText(attachmentId, "attachmentId must have a value");
Assert.hasText(rev, "Revision may not be null or empty");
if (LOG.isTraceEnabled()) {
LOG.trace("fetching attachment for doc: {} attachmentId: {}", id,
attachmentId);
}

HttpResponse r = restTemplate.get(dbURI.append(id).append(attachmentId).param("rev", rev)
.toString());
return new AttachmentInputStream(attachmentId, r.getContent(),
r.getContentType(), r.getContentLength());
}