adds check upload
This commit is contained in:
parent
0d92316992
commit
002734f692
@ -15,6 +15,22 @@ public class ImageApiTests : ApiTestsBase
|
||||
_imageApi = new ImageApi(Context, new NullLogger<ImageApi>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadyForUpload_should_return_correct_value()
|
||||
{
|
||||
SetJsonResult(@"{stat: ""ok"",
|
||||
result: {
|
||||
message: null,
|
||||
ready_for_upload: true
|
||||
}}");
|
||||
|
||||
var isReady = await _imageApi.ReadyForUploadAsync();
|
||||
|
||||
CorrectMethodShouldGetCalled("pwg.images.checkUpload");
|
||||
|
||||
isReady.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AddChunk_should_post_base64_encoded_data()
|
||||
{
|
||||
|
12
PiwigoDotnet/Piwigo.Client/Contract/CheckUpload.cs
Normal file
12
PiwigoDotnet/Piwigo.Client/Contract/CheckUpload.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public class CheckUpload
|
||||
{
|
||||
[JsonProperty("message")]
|
||||
public string? Message { get; init; }
|
||||
|
||||
[JsonProperty("ready_for_upload")]
|
||||
public bool IsReady { get; init; }
|
||||
}
|
@ -6,6 +6,34 @@ public interface IImageApi
|
||||
{
|
||||
Task AddChunkAsync(byte[] data, string originalSum, int position, CancellationToken cancellationToken = default);
|
||||
|
||||
Task<bool> ReadyForUploadAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
Task<PagedImages> GetImages(int albumId, bool recursive, PagingInfo page, ImageFilter filter, ImageOrder order = ImageOrder.Name,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/*
|
||||
add
|
||||
addComment
|
||||
addFile
|
||||
addSimple
|
||||
checkFiles
|
||||
delete
|
||||
deleteOrphans
|
||||
emptyLounge
|
||||
exist
|
||||
-> formats
|
||||
delete
|
||||
searchImage
|
||||
getInfo
|
||||
rate
|
||||
search
|
||||
setInfo
|
||||
setMd5sum
|
||||
setPrivacyLevel
|
||||
setRank
|
||||
syncMetadata
|
||||
upload
|
||||
uploadAsync
|
||||
uploadCompleted
|
||||
*/
|
||||
}
|
@ -31,6 +31,12 @@ public class ImageApi : IImageApi
|
||||
await _context.PostAsync<PiwigoResponse>(_logger, "pwg.images.addChunk", formParams, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<bool> ReadyForUploadAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var response = await _context.PostAsync<PiwigoResponse<CheckUpload>>(_logger, "pwg.images.checkUpload", new Dictionary<string, string>(), cancellationToken);
|
||||
return response.Result.IsReady;
|
||||
}
|
||||
|
||||
public async Task<PagedImages> GetImages(int albumId, bool recursive, PagingInfo page, ImageFilter filter, ImageOrder order = ImageOrder.Name,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user