You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.
I'm using couchdb to store attachments that I need to display in the browser.
The data is uploaded from an html input and then processed when saveDoc is called:
getFileData: function(file){
var reader = new FileReader();
return new Promise(function(accept, reject){
reader.onload = (e) => {
accept(e.target.result)
};
reader.readAsDataURL(file);
})
},
saveDoc: function(name, type, filedata, url){
console.log(filedata)
var self=this
return new Promise(function(accept, reject){
self.getData(url).then(data => {
var rev = data['_rev']
console.log(url + ' is the url')
console.log(name + ' is the filename')
documentation.attachment.insert(url, name, filedata, type,
{ rev: rev }, function(err, body) {
if (!err){
console.log(body);
}
else {
console.log(err)
}
})
}).catch(err => {
console.log(err)
})
})
},
I don't get any errors while uploading from the console. But when I navigate to where the attachment should be in the console, I see a browser message telling me the data can't be displayed (for pdf/images), or I see a base64 string that looks like this:
data:image/png;base64,iVBOR...
when the attachment is an html document.
(The data being logged on saveDoc looks like this: data:application/pdf;base64,JVBER...)
The correct content type as well as a reasonable length is being displayed in my couchdb admin with metadata on the files, so there are no obvious header problems. Can anyone think of any other reason this might not be working in the browser?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm using couchdb to store attachments that I need to display in the browser.
The data is uploaded from an html input and then processed when saveDoc is called:
I don't get any errors while uploading from the console. But when I navigate to where the attachment should be in the console, I see a browser message telling me the data can't be displayed (for pdf/images), or I see a base64 string that looks like this:
data:image/png;base64,iVBOR...
when the attachment is an html document.
(The data being logged on
saveDoc
looks like this:data:application/pdf;base64,JVBER...
)The correct content type as well as a reasonable length is being displayed in my couchdb admin with metadata on the files, so there are no obvious header problems. Can anyone think of any other reason this might not be working in the browser?
The text was updated successfully, but these errors were encountered: