When I add an image attachment to a document on the touchdb client -- following which I can get the attachment and display it locally -- the attachment does not show up on the couchdb server. To check, I can see the local document size go from 100kB to 600kB when I add a photo, but the remote document size only increases from 20kB to 33kB. (curl -X GET ../_all_docs output below).
Other android clients replicating with couchdb crash when trying to get the attachment from their local touchdb. The document name, however gets replicated correctly, which indicates that replication (minus the attachments) seems to work fine across touchdb and couchdb.
Let me know if you have any suggestions! Thanks, Mohit
Setup: Touchdb-android(JB)-client replicating push and pull with Couchdb 1.2.0
Code for creating attachment on touchdb client: public void insertPhoto(Photos photo) { String imagePath = photo.getUri(); File file = new File(imagePath); InputStream data = null; try { data = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String contentType = "image/jpeg";
AttachmentInputStream a = new AttachmentInputStream(new String(photo.getTimeStamp()), data, contentType);
But these tests seem to cover adding and retrieving attachments from a local database only...I am able to attach images to couchdb documents using futon, so I'm assuming the problem might be with either ektorp or touchdb's attachment/replication api implementation. Or with my implementation above :-)
Please let me know if you have any thoughts on this!
On Thu, Oct 25, 2012 at 7:04 PM, Mohit <mohit.tiw...@gmail.com> wrote:
> update: I tried the touchdb testapp, and the unit tests for attachments and
> attachments-using-ektorp both pass.
> But these tests seem to cover adding and retrieving attachments from a local
> database only...I am able to attach images to couchdb documents using futon,
> so I'm assuming the problem might be with either ektorp or touchdb's
> attachment/replication api implementation.
> Or with my implementation above :-)
> Please let me know if you have any thoughts on this!
I'm pretty sure the problem is not in Ektorp, it is in the replicator
implementation. The TouchDB-Android replicator is a mess and I
haven't any time to work on it for about 2 months now.
Did you make any progress yet on the TouchDB-Android replicator? I seem to be having a similar problem when creating attachments. I am trying to add an attachment to an existing document using the following piece of code:
final File attachmentFile = new File(URI.create(uri.toString())); final String contentType = "image/jpeg"; final AttachmentInputStream attachmentContents = new AttachmentInputStream(attachmentFile.getName(), new FileInputStream(attachmentFile), contentType); couchDbConnector.createAttachment(resourceId, revision, attachmentContents);
Note that *uri* points to a valid file, and both *resourceId* and *revision*are also correct.
I'm not getting any errors in the log but after replicating to the central CouchDB, the document has no attachments whatsoever. Even worse: any existing attachments seem to have been removed from the document as well. The local version of the document does seem to have the attachment attached correctly.
I haven't yet gone back to working on TouchDB-Android, but I hope to this
week. First up will be merging the replicator fixes branch to mainline (no
one reported it being worse than the main branch, and I feel it is better).
Next will be seeing why attachments aren't getting pushed.
What I can say is that if your attachments look correct in TouchDB (which
seems to be what you're saying), then there is no need to review the code
that creates the attachment. The problem must be in the replicator.
On Mon, Dec 3, 2012 at 6:57 AM, Bart <bart.sme...@gmail.com> wrote:
> Hi Marty,
> Did you make any progress yet on the TouchDB-Android replicator? I seem to
> be having a similar problem when creating attachments. I am trying to add
> an attachment to an existing document using the following piece of code:
> final File attachmentFile = new File(URI.create(uri.toString()));
> final String contentType = "image/jpeg";
> final AttachmentInputStream attachmentContents = new
> AttachmentInputStream(attachmentFile.getName(), new
> FileInputStream(attachmentFile), contentType);
> couchDbConnector.createAttachment(resourceId, revision,
> attachmentContents);
> Note that *uri* points to a valid file, and both *resourceId* and *
> revision* are also correct.
> I'm not getting any errors in the log but after replicating to the central
> CouchDB, the document has no attachments whatsoever. Even worse: any
> existing attachments seem to have been removed from the document as well.
> The local version of the document does seem to have the attachment
> attached correctly.
Hi Marty, is there any progress on the TouchDB attachments Replication. It seems that Attachments are locally present, but not in cloud CouchDB. Thanks, Paschal
On Dec 12, 2012, at 12:00 AM, Paschal Maduhu <maduhu1...@gmail.com<mailto:maduhu1...@gmail.com>> wrote:
is there any progress on the TouchDB attachments Replication.
Looking at the commit history of the repo<https://github.com/couchbaselabs/TouchDB-Android/commits/master> is a good way to answer questions like that.
Marty has said several times recently that he hasn’t had time to work on TouchDB in recent months, but plans to start again soon.