Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: #54

Open
2 tasks done
zaksnet opened this issue Nov 1, 2024 · 0 comments
Open
2 tasks done

🐛 Bug Report: #54

zaksnet opened this issue Nov 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zaksnet
Copy link

zaksnet commented Nov 1, 2024

👟 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?

@zaksnet zaksnet added the bug Something isn't working label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant