Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlodotexe committed Nov 16, 2024
2 parents 8478efa + a12f990 commit d8b77d9
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/CoreApi/DupsResponse.cs
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; }
}

}
50 changes: 50 additions & 0 deletions src/CoreApi/FilestoreApi.cs
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);
}
}

}
18 changes: 18 additions & 0 deletions src/CoreApi/FilestoreKey.cs
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; }
}

}
41 changes: 41 additions & 0 deletions src/CoreApi/FilestoreObjectResponse.cs
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; }
}

}
2 changes: 1 addition & 1 deletion src/CoreApi/KeyApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ internal KeyApi(IpfsClient ipfs)
throw new NotImplementedException();
}
}
}
}
5 changes: 5 additions & 0 deletions src/IpfsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public IpfsClient()
Dag = new DagApi(this);
Object = new ObjectApi(this);
FileSystem = new FileSystemApi(this);
FilestoreApi = new FilestoreApi(this);
Mfs = new MfsApi(this);
PubSub = new PubSubApi(this);
Key = new KeyApi(this);
Expand Down Expand Up @@ -163,6 +164,10 @@ public IpfsClient(string host)
/// <inheritdoc />
public IFileSystemApi FileSystem { get; private set; }


/// <inheritdoc />
public IFilestoreApi FilestoreApi { get; private set; }

/// <inheritdoc />
public IMfsApi Mfs { get; private set; }

Expand Down

0 comments on commit d8b77d9

Please sign in to comment.