public async Task <Cid> PutAsync( byte[] data, string contentType = Cid.DefaultContentType, string multiHash = MultiHash.DefaultAlgorithmName, bool pin = false, CancellationToken cancel = default(CancellationToken)) { var options = new List <string>(); if (multiHash != MultiHash.DefaultAlgorithmName || contentType != Cid.DefaultContentType) { options.Add($"mhtype={multiHash}"); options.Add($"format={contentType}"); } var json = await ipfs.UploadAsync("block/put", cancel, data, options.ToArray()); var info = JObject.Parse(json); Cid cid = (string)info["Key"]; if (pin) { await ipfs.Pin.AddAsync(cid, recursive : false, cancel : cancel); } return(cid); }
public async Task <string> UploadIPFSAsync(string fileName) { var client = new IpfsClient(); string text = await client.FileSystem.ReadAllTextAsync(fileName); string response = ""; using (StreamReader sr = new StreamReader(fileName)) { var r = new string [0]; response = await client.UploadAsync("add", System.Threading.CancellationToken.None, sr.BaseStream, fileName, r); } return(response); }