adds update extension method to update existing images
All checks were successful
piwigodotnet/pipeline/head This commit looks good
All checks were successful
piwigodotnet/pipeline/head This commit looks good
This commit is contained in:
parent
518dd58cde
commit
5e8c277b9b
@ -26,6 +26,29 @@ public static class PiwigoClientExtensions
|
|||||||
return await client.Image.AddAsync(metaData, cancellationToken);
|
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)
|
public static async Task<ImageUploaded> UploadImageAsync(this IPiwigoClient client, FileInfo imageToUpload, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (client == null)
|
if (client == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user