I'm using node and cradle to upload and save attachments (in this case
images), however, I get a
error: conflict
reason: "document update conflict"
status: 409.
The right doc._id and doc._rev attributes are transmitted, what else can
cause this error?
Here is my server side code:
exports.addLogo = function(req, res) {
var business,
businessName = req.body.businessname;
if ( req.files ) {
// get business data
db.view('business/getByBusinessName', { key: businessName },
function(err, doc) {
if ( err ) {
res.send({ header: 'Upload business logo', message:
err.reason, type: 'error'});
}
else {
business = doc[0].value;
// add business logo to couchdb document
db.saveAttachment(
business._id,
business._rev,
req.files.logo.type,
fs.createReadStream(req.files.logo.path),
function( att_err, data ) {
if ( att_err ) {
console.log('Logo upload error: ' +
att_err.reason);
res.send({ header: 'Upload business logo',
message: att_err.reason, type: 'error'});
}
else {
console.log(data);
res.send({ response: 'ok' });
}
});
}
});
}
};