Open saskakol opened 7 years ago
So you might be able to by using the blob mechanism in the browser. Are you using this in nodejs or the browser?
@silentcicero I'm using the browser. I actually figured out that I can just store a base64 string, which should work fine for what I'm doing. Thanks for the help though :)
Btw, what is a good IPFS node to use? Infura doesn't allow it to be used in projects without explicit permission, and I would need it for a hackathon. (I don't know how fast they will respond) Are there any alternatives?
@SilentCicero i'm trying to upload png/jpg files using blob mechanism, uploading works well, but when i watch these images using gateway, it seems like they are corrupted. If i upload files in the same way using js-ipfs-api, images are not corrupted. Do you know what could be the problem? Here's the code and example of corrupted image:
function uploadImage(file) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = event => resolve(event.target.result);
fileReader.onerror = error => reject(error);
fileReader.readAsArrayBuffer(file);
})
.then(arrayBuffer => (new Promise((resolve, reject) => {
ipfs.add(Buffer.from(arrayBuffer), (error, hash) => error ? reject(error) : resolve(hash))
})))
}
http://ipfs.io/ipfs/QmPTP3sjiXGy9jQcEZhexRYMSx5ZhSGdofHDkzG5DpvaQb
Thanks!
@iSasFTW I would recommend just starting a local node up or using the main IPFS gateway if that is still running (they have a high performance cluster running, I believe for free).
@ngaer I'll try to complete this task myself. Not sure why it would be currupted. Let me ask Pelle:
@pelle any thoughts on the above?
I think it's because we wrote our own Blob wrapper, and it may be wrapping the data twice.
@ngaer have you figured anything out, @pelle and I are too busy to investigate, but I will be using this module eventually to do file upload.
No, i do not have much time for this too, so for now i decided to use js-ipfs-api on server side.
HI i have added one json object in IPFS using addJson method. But while i am trying to get the same json object back using catJson with proper hash code i am getting the json ..but the output json is not a valid json object. How can i get the parsed json object ?
I use little hack for upload images - convert to svg
const reader = new FileReader()
reader.onloadend = async function () {
const fileContents = `<svg xmlns="http://www.w3.org/2000/svg">
<image href="${reader.result}" />
</svg>`
const CID = await IPFS.add(fileContents)
}
reader.readAsDataURL(this.files[0])
Hi! I have a quick question: Is it possible to upload other types of files over ipfs-mini than just text? I would need to upload .gif files, and I don't know if I can use IPFS.js, so came to ask here.
Thanks, Sas :)