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 Jan 14, 2020. It is now read-only.
The method ipfsService.saveDataURIAsFile seems sub-optimal.
I haven't had time to test thoroughly on Node and Browser but we should be able to replace it with something that does not involve converting every single byte into an Uint8Array.
Something like this:
async saveDataURIAsFile(dataURI) {
let binary
if (typeof Blob === 'undefined') {
binary = new Buffer(dataURI.split(',')[1], 'base64')
} else {
const mimeString = dataURI
.split(',')[0]
.split(':')[1]
.split(';')[0]
const data = new Buffer(dataURI.split(',')[1], 'base64')
binary = new Blob([data], {type: mimeString})
}
return await this.saveFile(binary)
}
While doing that, we should add some unit test on the back-end for uploading Data URI.
Here is a snippet for creating a Data URI for an image:
I remember working on that and having to do some strange things to maintain both node and browser compatibility. And also maintain support across different browsers. I don't remember the exact details but I'd suspect what I've done was mostly for compatibility reasons. I'm sure it can be improved though!
The method ipfsService.saveDataURIAsFile seems sub-optimal.
I haven't had time to test thoroughly on Node and Browser but we should be able to replace it with something that does not involve converting every single byte into an Uint8Array.
Something like this:
While doing that, we should add some unit test on the back-end for uploading Data URI.
Here is a snippet for creating a Data URI for an image:
The text was updated successfully, but these errors were encountered: