sdk-generator icon indicating copy to clipboard operation
sdk-generator copied to clipboard

🐛 Bug Report: HTTP call to `Client` throws error due to he `HttpMethod` enum not being exported from `client.dart`

Open hanskokx opened this issue 2 years ago • 8 comments

👟 Reproduction steps

When I attempt to make an HTTP call to the Client, I am unable to due to the HttpMethod enum not being exported from client.dart:

await client.call(
  HttpMethod.get,
  path: '/',
);

👍 Expected behavior

I should be able to make a call to the Client using the provided enum.

👎 Actual Behavior

The HttpMethod enum is not exported from client.dart, therefore I am unable to use the call method on the Client.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Something else

🧱 Your Environment

This is a client issue, not a server issue.

My pubspec.yaml specifies appwrite: ^9.0.1.

👀 Have you spent some time to check if this issue has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

hanskokx avatar Aug 15 '23 21:08 hanskokx

Hey @hanskokx , may I know the reason why you are using client.call ?

joeyouss avatar Aug 29 '23 15:08 joeyouss

@joeyouss It's been a couple of weeks since I filed this (and I've since moved on from the project and taken a vacation). I can no longer recall why I was trying to call the client directly. :)

hanskokx avatar Aug 29 '23 15:08 hanskokx

hI @hanskokx , apologies for the delayed response so the reason why I asked this is basically - client.call is an internal method used by us and not meant for public usage since it won't be working as expected by you. I understand, this might have been a bit confusing and for everything that is usable - our docs are a reference for that https://appwrite.io/docs. Thank you so much for opening the issue and your reply!

joeyouss avatar Aug 29 '23 15:08 joeyouss

Not a problem! I think the reason was that I wanted to move a file from one bucket to another (e.g., private bucket to public bucket) without downloading/re-uploading the button. I thought maybe I could do it by calling the client directly. If I had a guess, that would be why I filed the bug.

hanskokx avatar Aug 29 '23 15:08 hanskokx

I totally get it but that won't actually help you do that. A potential solution could be using document-level permissions and changing the permissions on the file itself to public instead of moving it to a bucket with public permissions.

joeyouss avatar Aug 29 '23 15:08 joeyouss

Fair enough. I was working within my client's constraints, though. This is how they set it up. 🤷🏻‍♂️

hanskokx avatar Aug 29 '23 16:08 hanskokx

Oh, I understand

joeyouss avatar Aug 30 '23 09:08 joeyouss

@hanskokx I just noticed this. This is a fascinating approach, I mean, we don't expose the Client because it's really supposed to be an internal class. If you need to switch between buckets, you'll likely need to do something strange with the buffers.

You CAN do this by just not using the SDK at all and use HTTP directly. You'll probably struggle with the chunk-upload implementation a little for large files. They're just a nightmare for everyone 🥼 I lost many hairs when working without the SDK, but you can peep the generated SDK code and just copy it.

Checkout this page: https://appwrite.io/docs/rest

I really don't think we're going to support this any time soon though, but maybe this can be a community contribution, as a utility extension to the Appwrite SDKs?

Hope this is reasonable to hear ❤️

gewenyu99 avatar Sep 11 '23 17:09 gewenyu99