andrewgleave/CouchDBAttachmentUploader — pull request #5 by jpfiset (2012-04-19 14:23:32+00:00)
Title: Pass CouchDB response back to client

This pull request contains changes to allow a javascript client to consume the information returned by CouchDB after uploading an attachment. Also, the javascript plugin code has been modified to intercept this information and call the "failure" case in the event that an error is generated by CouchDB.

If the attachment is uploaded successfully, CouchDB returns a JSON structure that looks like this:

{ "ok":true, "id":"", "rev":"" }

In the case of a failure, CouchDB return HTTP OK (200) with a JSON structure that looks like this:

{ "error": "", "reason":"" }

The changes in this pull request are:

1. (CouchDBAttachmentUpload.m) In the case of a successful connection (HTTP 200), simply evaluate the JSON structure in the callback. This change pushes the JSON structure to the plugin function.

2. (cordova.plugin.couchdb-attachment-upload.js) In a JSON structure is received containing the "error" key, call the "failure" case instead of success.

3. (README.md) Added details on how to install the plugin