jeremy-ellis-tech / net-ipfs-http-client

.NET API client for the InterPlanetary File System (IPFS)
MIT License
78 stars 15 forks source link

Download the file using Hashkey #7

Closed pbpraveen1988 closed 8 years ago

pbpraveen1988 commented 8 years ago

Hello @TrekDev ,

I like your library and i am using it and i want to download the file using hash key and also want to show the peers and downloading progress in %, can you guide me on this issue.

Thank You

jeremy-ellis-tech commented 8 years ago

Showing peers and downloading a file is easy:

var client = new IpfsClient();

// Gives you an ICollection of multiaddresses you're connected to
var peers = await client.Swarm.Peers();

Stream outputStream = await client.Cat("Qm...");
// Write outputStream to a byte[] or file.

To show download percentage you can inject the IpfsClient with your own HttpClient which has your own Handler to show download completion as shown here

HttpClient httpClient; // httpClient with our handler.
var client = new IpfsClient(new Uri("http://127.0.0.1:5001"), httpClient);
pbpraveen1988 commented 8 years ago

Hello @TrekDev ,

Thank You for the solution , one question , var peers = await client.Swarm.Peers();

will search for particular file peer or peer is related to something for all files

I know this is silly but i am new to IPFS and distributing systems or network.

Thank You

jeremy-ellis-tech commented 8 years ago

@pbpraveen1988 I don't understand the question.

timothyparez commented 7 years ago

@pbpraveen1988 it will list all peers with opnen connections.
It does not allow you to specifically list peers hosting a certain file.

Reference: https://ipfs.io/docs/commands/#ipfs-swarm-peers