Skip to content

Commit d8b77d9

Browse files
committed
2 parents 8478efa + a12f990 commit d8b77d9

File tree

6 files changed

+136
-1
lines changed

6 files changed

+136
-1
lines changed

src/CoreApi/DupsResponse.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Ipfs.CoreApi;
2+
3+
namespace Ipfs.Http.CoreApi
4+
{
5+
/// <summary>
6+
/// Model holding response from <see cref="FilestoreApi"/> Dups command.
7+
/// </summary>
8+
public class DupsResponse : IDupsResponse
9+
{
10+
/// <summary>
11+
/// Any error in the <see cref="IFilestoreApi"/> Dups response.
12+
/// </summary>
13+
public string Err { get; set; }
14+
15+
/// <summary>
16+
/// The error in the <see cref="IFilestoreApi"/> Dups response.
17+
/// </summary>
18+
public string Ref { get; set; }
19+
}
20+
21+
}

src/CoreApi/FilestoreApi.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Ipfs.CoreApi;
2+
using Ipfs.Http.CoreApi;
3+
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Linq;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.IO;
8+
using System.Text;
9+
using System.Threading;
10+
using System.Threading.Tasks;
11+
12+
namespace Ipfs.Http
13+
{
14+
/// <inheritdoc/>
15+
public class FilestoreApi : IFilestoreApi
16+
{
17+
private IpfsClient ipfs;
18+
19+
/// <inheritdoc/>
20+
internal FilestoreApi(IpfsClient ipfs)
21+
{
22+
this.ipfs = ipfs;
23+
}
24+
25+
/// <inheritdoc/>
26+
public async Task<IFilestoreApiObjectResponse> ListAsync(string cid, bool fileOrder, CancellationToken token)
27+
{
28+
var json = await ipfs.DoCommandAsync("filestore/ls", token, cid, fileOrder.ToString());
29+
30+
return JsonConvert.DeserializeObject<FilestoreObjectResponse>(json);
31+
}
32+
33+
/// <inheritdoc/>
34+
public async Task<IFilestoreApiObjectResponse> VerifyObjectsAsync(string cid, bool fileOrder, CancellationToken token)
35+
{
36+
var json = await ipfs.DoCommandAsync("filestore/verify", token, cid, fileOrder.ToString());
37+
38+
return JsonConvert.DeserializeObject<FilestoreObjectResponse>(json);
39+
}
40+
41+
/// <inheritdoc/>
42+
public async Task<IDupsResponse> DupsAsync(CancellationToken token)
43+
{
44+
var json = await ipfs.DoCommandAsync("filestore/dups", token);
45+
46+
return JsonConvert.DeserializeObject<DupsResponse>(json);
47+
}
48+
}
49+
50+
}

src/CoreApi/FilestoreKey.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Ipfs.CoreApi;
2+
using Newtonsoft.Json;
3+
4+
namespace Ipfs.Http
5+
{
6+
/// <summary>
7+
/// Model for the hold filestore key
8+
/// </summary>
9+
public class FilestoreKey : IFilestoreKey
10+
{
11+
/// <summary>
12+
/// Key value.
13+
/// </summary>
14+
[JsonProperty("/")]
15+
public string _ { get; set; }
16+
}
17+
18+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Ipfs.CoreApi;
2+
3+
namespace Ipfs.Http
4+
{
5+
/// <summary>
6+
/// Model holding response to <see cref="IFilestoreApi"/>.
7+
/// </summary>
8+
public class FilestoreObjectResponse : IFilestoreApiObjectResponse
9+
{
10+
/// <summary>
11+
/// Holds any error message.
12+
/// </summary>
13+
public string ErrorMsg { get; set; }
14+
15+
/// <summary>
16+
/// Path to the file
17+
/// </summary>
18+
public string FilePath { get; set; }
19+
20+
/// <summary>
21+
/// The key to the Filestore.
22+
/// </summary>
23+
public FilestoreKey Key { get; set; }
24+
25+
/// <summary>
26+
/// The response offset.
27+
/// </summary>
28+
public string Offset { get; set; }
29+
30+
/// <summary>
31+
/// The size of the object.
32+
/// </summary>
33+
public string Size { get; set; }
34+
35+
/// <summary>
36+
/// The object status.k
37+
/// </summary>
38+
public string Status { get; set; }
39+
}
40+
41+
}

src/CoreApi/KeyApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ internal KeyApi(IpfsClient ipfs)
114114
throw new NotImplementedException();
115115
}
116116
}
117-
}
117+
}

src/IpfsClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public IpfsClient()
7373
Dag = new DagApi(this);
7474
Object = new ObjectApi(this);
7575
FileSystem = new FileSystemApi(this);
76+
FilestoreApi = new FilestoreApi(this);
7677
Mfs = new MfsApi(this);
7778
PubSub = new PubSubApi(this);
7879
Key = new KeyApi(this);
@@ -163,6 +164,10 @@ public IpfsClient(string host)
163164
/// <inheritdoc />
164165
public IFileSystemApi FileSystem { get; private set; }
165166

167+
168+
/// <inheritdoc />
169+
public IFilestoreApi FilestoreApi { get; private set; }
170+
166171
/// <inheritdoc />
167172
public IMfsApi Mfs { get; private set; }
168173

0 commit comments

Comments
 (0)