adds update extension method to update existing images
All checks were successful
piwigodotnet/pipeline/head This commit looks good

This commit is contained in:
Philipp Häfelfinger 2023-09-02 16:03:59 +02:00
parent 518dd58cde
commit 5e8c277b9b

View File

@ -26,6 +26,29 @@ public static class PiwigoClientExtensions
return await client.Image.AddAsync(metaData, cancellationToken);
}
public static async Task<ImageUploaded> UpdateImageAsync(this IPiwigoClient client, int imageId, FileInfo imageToUpload, ImageUpload metaData,
CancellationToken cancellationToken = default)
{
if (client == null)
{
throw new ArgumentNullException(nameof(client));
}
if (imageToUpload == null)
{
throw new ArgumentNullException(nameof(imageToUpload));
}
if (metaData == null)
{
throw new ArgumentNullException(nameof(metaData));
}
await client.CheckSupportedFileTypeAsync(imageToUpload, cancellationToken);
await UploadChunksAsync(client, imageToUpload, metaData.OriginalSum, cancellationToken);
return await client.Image.UpdateAsync(imageId, metaData, cancellationToken);
}
public static async Task<ImageUploaded> UploadImageAsync(this IPiwigoClient client, FileInfo imageToUpload, CancellationToken cancellationToken = default)
{
if (client == null)