adds check upload

This commit is contained in:
Philipp Häfelfinger 2022-10-22 20:36:20 +02:00
parent 0d92316992
commit 002734f692
4 changed files with 62 additions and 0 deletions

View File

@ -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()
{

View 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; }
}

View File

@ -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
*/
}

View File

@ -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)
{