// add attachment
var dbWriteStream = db.attachment.insert(doc._id, filename, null, type, {rev: doc._rev}, uploaded);
var fileReadStream = fs.createReadStream(file.path);
fileReadStream.on('error', error);
dbWriteStream.on('error', error);
fileReadStream.pipe(dbWriteStream);
function uploaded(err, body) {
if (err) {
console.log("[Attachment] Error in upload.");
if (err.status_code === 409) {
console.log('Attachment upload conflict, retry.');
addAttachment(req, res);
return;
}
else {
console.log("Unrecoverable error in upload", err);
clearTmp();
return error(err);
}
}
clearTmp();
....
}
on('end', ...)
was not successful that time i wrote that code
err
- Objekt zurückgibt, dies bedeutet automatisch, dass ok
== false und umgekehrt kein Error
- ok
ist immer true
OK, at the moment I have following problem:
I am trying to implement attachment upload in the right way.
As I mentioned I should do it in following steps
- db.get to get the updated versions (with `_attachments`)
- Add additional custom attachment meta data to the document
- db.insert - Save updated document
Can you verify it?
db.attachment.head
implementation?
@dscape
As I mentioned in nano
there is no db.head
And the best way to ensure that
it to create it?