Updates endpoint to match latest Codex
This commit is contained in:
parent
b8ce4c49d6
commit
c5cc15daa0
|
@ -62,14 +62,17 @@ namespace CodexPlugin
|
||||||
|
|
||||||
public string UploadFile(FileStream fileStream)
|
public string UploadFile(FileStream fileStream)
|
||||||
{
|
{
|
||||||
// private const string UploadFailedMessage = "Unable to store block";
|
return Http().HttpPostStream("data", fileStream);
|
||||||
|
|
||||||
return Http().HttpPostStream("upload", fileStream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream DownloadFile(string contentId)
|
public Stream DownloadFile(string contentId)
|
||||||
{
|
{
|
||||||
return Http().HttpGetStream("download/" + contentId);
|
return Http().HttpGetStream("data/" + contentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodexLocalDataResponse[] LocalFiles()
|
||||||
|
{
|
||||||
|
return Http().HttpGetJson<CodexLocalDataResponse[]>("local");
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodexSalesAvailabilityResponse SalesAvailability(CodexSalesAvailabilityRequest request)
|
public CodexSalesAvailabilityResponse SalesAvailability(CodexSalesAvailabilityRequest request)
|
||||||
|
|
|
@ -170,4 +170,30 @@ namespace CodexPlugin
|
||||||
{
|
{
|
||||||
public string cid { get; set; } = string.Empty;
|
public string cid { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CodexLocalData
|
||||||
|
{
|
||||||
|
public CodexLocalData(ContentId cid, CodexLocalDataManifestResponse manifest)
|
||||||
|
{
|
||||||
|
Cid = cid;
|
||||||
|
Manifest = manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentId Cid { get; }
|
||||||
|
public CodexLocalDataManifestResponse Manifest { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CodexLocalDataResponse
|
||||||
|
{
|
||||||
|
public string cid { get; set; } = string.Empty;
|
||||||
|
public CodexLocalDataManifestResponse manifest { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CodexLocalDataManifestResponse
|
||||||
|
{
|
||||||
|
public string rootHash { get; set; } = string.Empty;
|
||||||
|
public int originalBytes { get; set; }
|
||||||
|
public int blockSize { get; set; }
|
||||||
|
public bool @protected { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace CodexPlugin
|
||||||
//CodexDebugRepoStoreResponse[] GetDebugRepoStore();
|
//CodexDebugRepoStoreResponse[] GetDebugRepoStore();
|
||||||
ContentId UploadFile(TrackedFile file);
|
ContentId UploadFile(TrackedFile file);
|
||||||
TrackedFile? DownloadContent(ContentId contentId, string fileLabel = "");
|
TrackedFile? DownloadContent(ContentId contentId, string fileLabel = "");
|
||||||
|
CodexLocalData[] LocalFiles();
|
||||||
void ConnectToPeer(ICodexNode node);
|
void ConnectToPeer(ICodexNode node);
|
||||||
CodexDebugVersionResponse Version { get; }
|
CodexDebugVersionResponse Version { get; }
|
||||||
IMarketplaceAccess Marketplace { get; }
|
IMarketplaceAccess Marketplace { get; }
|
||||||
|
@ -121,6 +122,11 @@ namespace CodexPlugin
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CodexLocalData[] LocalFiles()
|
||||||
|
{
|
||||||
|
return CodexAccess.LocalFiles().Select(l => new CodexLocalData(new ContentId(l.cid), l.manifest)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
public void ConnectToPeer(ICodexNode node)
|
public void ConnectToPeer(ICodexNode node)
|
||||||
{
|
{
|
||||||
var peer = (CodexNode)node;
|
var peer = (CodexNode)node;
|
||||||
|
@ -205,5 +211,15 @@ namespace CodexPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Id { get; }
|
public string Id { get; }
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
return obj is ContentId id && Id == id.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,10 @@ namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
var primary = AddCodex(s => s.WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Warn, CodexLogLevel.Warn)));
|
var primary = AddCodex(s => s.WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Warn, CodexLogLevel.Warn)));
|
||||||
|
|
||||||
primary.UploadFile(GenerateTestFile(5.MB()));
|
var cid = primary.UploadFile(GenerateTestFile(5.MB()));
|
||||||
|
|
||||||
|
var content = primary.LocalFiles();
|
||||||
|
CollectionAssert.Contains(content.Select(c => c.Cid), cid);
|
||||||
|
|
||||||
var log = Ci.DownloadLog(primary);
|
var log = Ci.DownloadLog(primary);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue