Git Product home page Git Product logo

cloudflare's People

Contributors

luis901101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

osamamohammed98

cloudflare's Issues

Enhancement: imageApi - ability to specify image filename when uploading image using contentFromBytes

Hi,

Currently, when using contentFromBytes when uploading an image, all image file names on CloudFlare appear as 'image-from-bytes'

//From bytes
CloudflareHTTPResponse<CloudflareImage?> responseFromBytes = await cloudflare.imageAPI.upload(  
  contentFromBytes: DataTransmit<Uint8List>(data: imageBytes, progressCallback: (count, total) {  
    print('Upload progress: $count/$total');  
  })  
);

this seems to be because the HTTP post is specifying it as such. Please can the file name be abstracted so that we can specify it in imageAPI.upload() call?

@POST('/v1')
  @MultiPart()
  @Headers(RestAPIService.defaultHeaders)
  Future<HttpResponse<CloudflareResponse?>> uploadFromBytes({
    @Part(name: Params.file, fileName: 'image-from-bytes')
        required List<int> bytes,
    @Part() bool? requireSignedURLs,
    @Part() Map<String, dynamic>? metadata,
    @SendProgress() ProgressCallback? onUploadProgress,
    @CancelRequest() CancelToken? cancelToken,
  });

Getting error

The connection errored: The XMLHttpRequest onError callback was called. This typically indicates an error on the network layer. This indicates an error which most likely cannot be solved by the library

Basic constructor failing !isBasic assertion

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:

Future<void> savePhoto(File img) async {
  final cloudflare = Cloudflare.basic();
   await cloudflare.init();
      final response = await cloudflare.imageAPI.createDirectUpload();
      final dataUploadDraft = response.body;
      try {
        await cloudflare.imageAPI.directUpload(
            dataUploadDraft: dataUploadDraft!,
            contentFromFile: DataTransmit<File>(
                data: img,
                progressCallback: (count, total) {
                  print(
                      'Image upload to direct upload URL from file: $count/$total');
                }));
      } catch (e) {
        print(e);
      }}

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:

       final cloudflare = Cloudflare(
         accountId: "my_account_id",
         token: "my_token",
       );

I'm using cloudflare: ^3.1.0+16

Error while build project

Error:-
Launching lib\main.dart on DN2101 in debug mode...
lib\main.dart:1
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloudflare-1.3.0+11/lib/src/apiservice/stream_api.dart:832:36: Error: The getter 'name' isn't defined for the class 'MediaProcessingState'.

  • 'MediaProcessingState' is from 'package:cloudflare/src/enumerators/media_processing_state.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloudflare-1.3.0+11/lib/src/enumerators/media_processing_state.dart').
    package:cloudflare/…/enumerators/media_processing_state.dart:1
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'name'.
    status: status?.map((e) => e.name).join(','),

                                 ^^^^
    

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloudflare-1.3.0+11/lib/src/entity/cloudflare_stream_video.dart:328:44: Error: The getter 'name' isn't defined for the class 'ThumbnailFit'.

  • 'ThumbnailFit' is from 'package:cloudflare/src/enumerators/thumbnail_fit.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloudflare-1.3.0+11/lib/src/enumerators/thumbnail_fit.dart').
    package:cloudflare/…/enumerators/thumbnail_fit.dart:1
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'name'.

Flutter Version :- 2.5.3
Code Editor VSCode

please help me out ASAP, Thanks...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.