Open
Description
👟 Reproduction steps
When i use var file = await storage.GetFilePreview("6710e6320027465880b0", "67248ee6003b9780a4cc", output: ImageFormat.Jpeg);
👍 Expected behavior
It should get the byte array of the file.
👎 Actual Behavior
It throws an exception:
Appwrite.AppwriteException: Invalid `output` param: Value must be one of (jpg, jpeg, gif, png, webp)
at Appwrite.Client.Call[T](String method, String path, Dictionary`2 headers, Dictionary`2 parameters, Func`2 convert)
at Program.<Main>$(String[] args) in E:\appwrite\dotnet\TestApp\Program.cs:line 29
at Program.<Main>(String[] args)
The fix is simple in this repo, although i understand that this SDK is auto generated and the fix should be implemented in the generator:
public Task<byte[]> GetFilePreview(string bucketId, string fileId, long? width = null, long? height = null, Appwrite.Enums.ImageGravity? gravity = null, long? quality = null, long? borderWidth = null, string? borderColor = null, long? borderRadius = null, double? opacity = null, long? rotation = null, string? background = null, Appwrite.Enums.ImageFormat? output = null)
{
var apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview"
.Replace("{bucketId}", bucketId)
.Replace("{fileId}", fileId);
var apiParameters = new Dictionary<string, object?>()
{
{ "width", width },
{ "height", height },
{ "gravity", gravity },
{ "quality", quality },
{ "borderWidth", borderWidth },
{ "borderColor", borderColor },
{ "borderRadius", borderRadius },
{ "opacity", opacity },
{ "rotation", rotation },
{ "background", background },
// Change this
{ "output", output?.Value }
};
var apiHeaders = new Dictionary<string, string>()
{
{ "content-type", "application/json" }
};
return _client.Call<byte[]>(
method: "GET",
path: apiPath,
headers: apiHeaders,
parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!);
}
🎲 Appwrite version
Version 0.10.x
💻 Operating system
Linux
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct