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

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

Open
mariusbloemhof opened this issue Feb 13, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@mariusbloemhof
Copy link

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,
  });
@luis901101 luis901101 added the enhancement New feature or request label Feb 14, 2023
@luis901101
Copy link
Owner

Hi @mariusbloemhof and thanks for using the package, I just released v2.1.0+14 which allows you to specify custom file name for media upload. I also released new breaking change version due to dio and retrofit breaking changes.
Anyway I recommend you to avoid using signed upload to Cloudflare from client side, recommended way is to use unsigned upload by using directUploads, unless you are working on the server side in dart.

@mariusbloemhof
Copy link
Author

Hi @luis901101, thanks I will definitely try the new version and let you know if there are any issues.

Any comment as to why the preferred method of upload is DirectUpload?

Also, is there any specific reason why this should not be used for Flutter Web? I am currently using it for Web without issues, I simply changed settings to allow for CORS when testing from local

@luis901101
Copy link
Owner

Client side apps should not use signed upload for a security matter… documentation explains it. Anyway, the thing is for you to be able to do signed requests to cloudflare API, you need to use accountID+token+key or any of the 3 ways Cloudflare allows you to do signed requests… so you will have your cloudflare credentials stored on client side which is a security vulnerability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants