-
Notifications
You must be signed in to change notification settings - Fork 2
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
Basic constructor failing !isBasic assertion #5
Comments
Yep that's correct you can't use Here some important notes from package readme: |
Taken from your documentation: This would indicate that the createDirectUpload is, in fact, for unsigned access, wouldn't it? So if I'm needing to upload a photo from a flutter iOS app, which endpoint should I use in the since directUpload requires a DataUploadDraft in the body, which, I presume is only available by calling createDirectUpload. |
Trying this with Cloudflare.basic():
Uploads bytes, but throws a DioException status 400 at the end. (I replaced my client id with XXX above. Using valid url). Leaving out the uploadURL from the DataUploadDraft constructor throw an error. |
I agree it could be a bit confusing but that is the official documentation for My recommendation is for you to check cloudflare's official docs for the whole Cloudflare Images API so you can have the whole idea of functioning because some other things could be confusing as well. In my first comment I already mentioned what you need to do:
|
According to the 400 error code it is a bad request, the url you are using seems not right. I recommend you to check the Cloudflare's official documentation so you can understand how it works... otherwise you will be struggling with a test/error approach Check here Developers portal and here Cloudflare Image API. Also you could use the package sample code and integration tests to check how it work and what would be the expected results for each api endpoint. Check here this a test I just run to check image direct upload. |
Oh jeez - My apologies - I didn't realize that the two steps were discrete where the DataUploadDraft was initiated from the server and then the directUpload was from the client. |
Yep Cloudflare's documentation is not too clear and sometimes there are implicit contents that requires a previous reading to properly understand it. Anyway this package is a Dart Wrapper for the official Cloudflare's apis, that's why I decided to document the entire project using the official Cloudflare's documentation, so if anything is not clear the developer can go deeper checking the Cloudflare's documentation. |
Understood - I think the readme is where I'd like to add some color. You obviously know the APIs backward and front. I am new to both your package and to the Cloudflare Image/Stream APIs so I don't have the luxury of deep dives while also building my product. I could offer a fresh-eyed perspective. |
I'm using the API from a flutter app (iOS and Android). Based on the docs, being a client-app, I instantiate Cloudflare using the basic constructor:
On execution, I receive the following:
package: 'cloudflare/src/apiservice/image_api.dart': Failed assertion: line 429 pos 12: '!isBasic': Thsi endpoing requires an authorized request, check the Cloudflare constructure you are using and make sure you are using a valid 'accountId' and 'token'.
When I switch the non-basic constructor, it works perfectly:
I'm using cloudflare: ^3.1.0+16
The text was updated successfully, but these errors were encountered: