NPellet / visualizer

Other
43 stars 24 forks source link

CouchAttachments has no access to attachments if not public #978

Closed lpatiny closed 7 years ago

lpatiny commented 7 years ago

I don't know how to send credential so that couch attachments can load attachment of a non public view

stropitek commented 7 years ago

I always send credentials, it should work on private views

lpatiny commented 7 years ago

You are right. In fact it is when I load the image using image-js. I just used the URL so I don't know what should I do.

stropitek commented 7 years ago

With couchdb attachment you can get the data content as a Blob by doing

cdb.get(attachmentName, {responseType: 'blob'})

You can then convert the Blob to a dataUrl before passing it to image-js

function blobToDataURL(blob, callback) {
    var a = new FileReader();
    a.onload = function(e) {callback(e.target.result);}
    a.readAsDataURL(blob);
}
lpatiny commented 7 years ago

Not an easy solution ... how we could forward credential ? Can it be in the url somehow ?

targos commented 7 years ago

You have two options:

stropitek commented 7 years ago

Ok, didn't know withCredentials was an option in image-js