-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/amaid/net-ipfs-http-client
- Loading branch information
Showing
6 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Ipfs.CoreApi; | ||
|
||
namespace Ipfs.Http.CoreApi | ||
{ | ||
/// <summary> | ||
/// Model holding response from <see cref="FilestoreApi"/> Dups command. | ||
/// </summary> | ||
public class DupsResponse : IDupsResponse | ||
{ | ||
/// <summary> | ||
/// Any error in the <see cref="IFilestoreApi"/> Dups response. | ||
/// </summary> | ||
public string Err { get; set; } | ||
|
||
/// <summary> | ||
/// The error in the <see cref="IFilestoreApi"/> Dups response. | ||
/// </summary> | ||
public string Ref { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Ipfs.CoreApi; | ||
using Ipfs.Http.CoreApi; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ipfs.Http | ||
{ | ||
/// <inheritdoc/> | ||
public class FilestoreApi : IFilestoreApi | ||
{ | ||
private IpfsClient ipfs; | ||
|
||
/// <inheritdoc/> | ||
internal FilestoreApi(IpfsClient ipfs) | ||
{ | ||
this.ipfs = ipfs; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<IFilestoreApiObjectResponse> ListAsync(string cid, bool fileOrder, CancellationToken token) | ||
{ | ||
var json = await ipfs.DoCommandAsync("filestore/ls", token, cid, fileOrder.ToString()); | ||
|
||
return JsonConvert.DeserializeObject<FilestoreObjectResponse>(json); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<IFilestoreApiObjectResponse> VerifyObjectsAsync(string cid, bool fileOrder, CancellationToken token) | ||
{ | ||
var json = await ipfs.DoCommandAsync("filestore/verify", token, cid, fileOrder.ToString()); | ||
|
||
return JsonConvert.DeserializeObject<FilestoreObjectResponse>(json); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<IDupsResponse> DupsAsync(CancellationToken token) | ||
{ | ||
var json = await ipfs.DoCommandAsync("filestore/dups", token); | ||
|
||
return JsonConvert.DeserializeObject<DupsResponse>(json); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Ipfs.CoreApi; | ||
using Newtonsoft.Json; | ||
|
||
namespace Ipfs.Http | ||
{ | ||
/// <summary> | ||
/// Model for the hold filestore key | ||
/// </summary> | ||
public class FilestoreKey : IFilestoreKey | ||
{ | ||
/// <summary> | ||
/// Key value. | ||
/// </summary> | ||
[JsonProperty("/")] | ||
public string _ { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Ipfs.CoreApi; | ||
|
||
namespace Ipfs.Http | ||
{ | ||
/// <summary> | ||
/// Model holding response to <see cref="IFilestoreApi"/>. | ||
/// </summary> | ||
public class FilestoreObjectResponse : IFilestoreApiObjectResponse | ||
{ | ||
/// <summary> | ||
/// Holds any error message. | ||
/// </summary> | ||
public string ErrorMsg { get; set; } | ||
|
||
/// <summary> | ||
/// Path to the file | ||
/// </summary> | ||
public string FilePath { get; set; } | ||
|
||
/// <summary> | ||
/// The key to the Filestore. | ||
/// </summary> | ||
public FilestoreKey Key { get; set; } | ||
|
||
/// <summary> | ||
/// The response offset. | ||
/// </summary> | ||
public string Offset { get; set; } | ||
|
||
/// <summary> | ||
/// The size of the object. | ||
/// </summary> | ||
public string Size { get; set; } | ||
|
||
/// <summary> | ||
/// The object status.k | ||
/// </summary> | ||
public string Status { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,4 +114,4 @@ internal KeyApi(IpfsClient ipfs) | |
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters