-
Notifications
You must be signed in to change notification settings - Fork 16
Implemented Filestore api #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
71f6c47
added FilesStore api
9fe4cb2
Update src/IpfsClient.cs
amaid 616f87b
Fixed deserialization for filestore
338517e
conflict resolution
6b01a70
removed test app code files
04233f6
Update src/CoreApi/FilestoreObjectResponse.cs
amaid d73f62d
Code cleanup
ced92f8
conflict resolution
a12f990
Update src/CoreApi/FilestoreKey.cs
Arlodotexe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,68 @@ | ||
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; | ||
using static Ipfs.Http.CoreApi.FilestoreApi; | ||
|
||
namespace Ipfs.Http.CoreApi | ||
{ | ||
/// <summary> | ||
/// Concrete implementation of <see cref="IFilestoreApi"/>. | ||
/// </summary> | ||
public class FilestoreApi : IFilestoreApi | ||
amaid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
private IpfsClient ipfs; | ||
|
||
internal FilestoreApi(IpfsClient ipfs) | ||
{ | ||
this.ipfs = ipfs; | ||
} | ||
|
||
/// <summary> | ||
/// List async api for <see cref="IFilestoreApi"/>. | ||
/// </summary> | ||
/// <param name="cid"></param> | ||
/// <param name="token"></param> | ||
/// <param name="fileOrder"></param> | ||
/// <returns></returns> | ||
public async Task<IFilesStoreApiObjectResponse> ListAsync(string cid, CancellationToken token, bool fileOrder) | ||
{ | ||
var json = await ipfs.DoCommandAsync("filestore/ls", token, cid, fileOrder.ToString()); | ||
|
||
return JsonConvert.DeserializeObject<FilestoreObjectResponse>(json); | ||
} | ||
|
||
/// <summary> | ||
/// Object verification api for <see cref="IFilestoreApi"/>. | ||
/// </summary> | ||
/// <param name="cid"></param> | ||
/// <param name="fileOrder"></param> | ||
/// <param name="token"></param> | ||
/// <returns></returns> | ||
public async Task<IFilesStoreApiObjectResponse> VerifyObjectsAsync(string cid, bool fileOrder, CancellationToken token) | ||
{ | ||
var json = await ipfs.DoCommandAsync("filestore/verify", token, cid, fileOrder.ToString()); | ||
|
||
return JsonConvert.DeserializeObject<FilestoreObjectResponse>(json); | ||
} | ||
|
||
/// <summary> | ||
/// Executes Dups command in <see cref="IFilestoreApi"/>. | ||
/// </summary> | ||
/// <param name="token"></param> | ||
/// <returns></returns> | ||
public async Task<IDupsResponse> DupsAsync(CancellationToken token) | ||
{ | ||
var json = await ipfs.DoCommandAsync("filestore/dups", token); | ||
|
||
return JsonConvert.DeserializeObject<DupsResponse>(json); | ||
} | ||
} | ||
|
||
} |
This file contains hidden or 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.CoreApi | ||
{ | ||
/// <summary> | ||
/// Model holding response to <see cref="IFilestoreApi"/>. | ||
/// </summary> | ||
public class FilestoreObjectResponse : IFilesStoreApiObjectResponse | ||
{ | ||
/// <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 IFilesStoreKey Key { get; set; } | ||
amaid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// <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 hidden or 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.CoreApi | ||
{ | ||
/// <summary> | ||
/// Model for the hold filestore key | ||
/// </summary> | ||
public class Key : IFilesStoreKey | ||
amaid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/// <summary> | ||
/// Key value. | ||
/// </summary> | ||
[JsonProperty("/")] | ||
public string Value { get; set; } | ||
} | ||
|
||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.