Tuesday, 14 March 2017

What is the data-type return of Couchbase when you 'Get' an attachment (jpg)

I'm new in couchbase.

I'm using node js express + couchbase.

This is my model for creating an http request for getting an image attachment on couchbase server:

ModuleModel.getAttachment = function(id, name, sessionId, callback){

var options = {
url: config.sync.url+id+'/'+name,
method: 'GET',
headers: { 'Accept': 'image/jpeg', "Cookie":sessionId }
};
request(options, function(error, response) {
  if(error){
      console.log("1"+error);
      return callback(error, null);
  }
console.log(response.body);
     callback(null,response.body);

}); }

it returns a very long string like this:

����QWc��{wfE,�Q'�Q��9Y>ռg�X����>�<շ�� ���t�{o��5ۓ�:�Sӻ��r�vuSO�IV�����dZ#5M7�F�Y.XB����Vv�4sT�y����ߦ �P����=>'���GQW}��s�%zJ�q;�\�=l���P

I've tried to convert that string into base64 then into image but id didn;t work

How to convert that data into image? Thanks!



via Emel Nacion

No comments:

Post a Comment