Closed Jawadlord closed 5 years ago
Plus I dont want to any local node running.
The IpfsClient
is designed to communicate with an IPFS daemon (a server that supports the IPFS HTTP-API protocol). My understanding is that https://ipfs.io/ipfs/x
is a service that returns the HTTP representation of x
and is not a daemon. Perhaps @diasdavid can shed some light.
I am surprised that the code for reading file from ipfs.io
works. I will investigate and get back to you.
Well, actually I believe its just using HttpWebRequest and HttpWebResponse methods for the files and text etc. Since getting the file is just like normal GetResponse, it reads the file from the host we provide. Having said that, means that Adding the file can also be possible.
Also please let me know if you have any other solution for uploading the files to IPFS without using local node. Thanks
I suggest you ask https://discuss.ipfs.io/ for a solution.
I am trying to add the files to the IPFS, (I am not running any local node). I can get the files from IPFS but I cant upload/add any text or file.
READING FILE FROM IPFS.IO (working fine) IpfsClient ipfs = new IpfsClient("https://ipfs.io/ipfs"); var file = await ipfs.FileSystem.ReadFileAsync("QmSRrpQ8H1RyhSvprZBUrQrkLUSq5XdyX8KdfpxJZgK2mx"); Image image = Bitmap.FromStream(file);
ADD FILE/TEXT TO IPFS IpfsClient ipfs = new IpfsClient("https://ipfs.io/ipfs"); var result = await ipfs.FileSystem.AddTextAsync("HelloWorld"); >> gives me following error
System.Net.Http.HttpRequestException: 'Invalid IPFS command: https://ipfs.io/api/v0/add?chunker=size-262144'
You can check this in any C# application (winforms/xamarin android) all gives me the same error.
Please suggest. Thanks
+1 Same issue I am facing, have you resolve this issue ? or any workaround @richardschneider @Jawadlord
Hi @shamtroon, I resolved that by using IPFS Infura URL. Can't believe still there is no working solution for this code snippet. Anyway below is my working code
//Upload to IPFS
Ipfs.Api.IpfsClient ipfs = new Ipfs.Api.IpfsClient("https://ipfs.infura.io:5001");
var fileResult = await ipfs.FileSystem.AddTextAsync("HelloWorld");
string ipfsHash = fileResult.Id.Hash.ToString();
//Reading from IPFS
IpfsClient ipfs = new IpfsClient("https://ipfs.io/ipfs");
var text = await ipfs.FileSystem.ReadTextAsync(ipfsHash);
//Or paste the following URL in webbrowser / download string via webclient etc
"https://ipfs.io/ipfs/" + result.Id.Hash.ToString();
Let me know :)
Hi @shamtroon, I resolved that by using IPFS Infura URL. Can't believe still there is no working solution for this code snippet. Anyway below is my working code
//Upload to IPFS Ipfs.Api.IpfsClient ipfs = new Ipfs.Api.IpfsClient("https://ipfs.infura.io:5001"); var fileResult = await ipfs.FileSystem.AddTextAsync("HelloWorld"); string ipfsHash = fileResult.Id.Hash.ToString(); //Reading from IPFS IpfsClient ipfs = new IpfsClient("https://ipfs.io/ipfs"); var text = await ipfs.FileSystem.ReadTextAsync(ipfsHash); //Or paste the following URL in webbrowser / download string via webclient etc "https://ipfs.io/ipfs/" + result.Id.Hash.ToString();
Let me know :)
Thanks @Jawadlord . I already solved this issue by using same Infura url.
Thanks again.
I am trying to add the files to the IPFS, (I am not running any local node). I can get the files from IPFS but I cant upload/add any text or file.
READING FILE FROM IPFS.IO (working fine) IpfsClient ipfs = new IpfsClient("https://ipfs.io/ipfs"); var file = await ipfs.FileSystem.ReadFileAsync("QmSRrpQ8H1RyhSvprZBUrQrkLUSq5XdyX8KdfpxJZgK2mx"); Image image = Bitmap.FromStream(file);
ADD FILE/TEXT TO IPFS IpfsClient ipfs = new IpfsClient("https://ipfs.io/ipfs"); var result = await ipfs.FileSystem.AddTextAsync("HelloWorld"); >> gives me following error
System.Net.Http.HttpRequestException: 'Invalid IPFS command: https://ipfs.io/api/v0/add?chunker=size-262144'
You can check this in any C# application (winforms/xamarin android) all gives me the same error.
Please suggest. Thanks