We are building an application where it will be possible for users to modify the same document on a mobile device, as well as in a web browser.
We are using Server 5.0 and Mobile 2.0 DB (C#). The web application we have created so far, does all the queries on the couchbase server via direct N1QL queries and utilising the NodeJS SDK.
We were able to successfully attach images to documents on the mobile app, and they get synced successfully. Now how is it possible to get these attached images in couch base server? I’ve found that this is not supported, and the Sync Gateway API should be used, is this still true? If so, are there any plans to add this to couch base server or the SDK’s any time soon?
function getImage(req, res) {
let imageKey = `_sync:att:${req.blobId}`; // blobId = sha value from _attachments
bucket.get(imageKey, { xattr: true }, function(error, result) {
// result.value = Buffer type
res.writeHead(200, {
'Content-Type': 'image/jpeg',
'Content-Length': 23817,
'Content-Disposition': 'attachment; filename="firstattachment"'
});
// Ideally, above properties should be retrieved from the doc itself, possible to verify the actual link between document and attachment as well
return res.end(result.value);
});
As you can see, this works, but it seems a bit messy, having to include the _sync:att: in the attachment id etc