How can I upload image file to files using Flutter?

How can I upload an image jpg file to the files?

Hi Hassan,

You should use the following API to upload files:


1 Like

Yes I knew that, now I am having problem in converting image to file in Flutter. I cannot find the way for that. :frowning:
Thanks though!

1 Like

If your image is represented as an array of bytes, you can use the following API:


My image is of Image type, then it is not a file as well. And if it is not a file, I will not be able to upload it.
I am just looking for a way to convert it to a file and all will be done.

1 Like

A file is something that is present in the file system. If you have an image from the camera, you should use the “upload from the byte array” API. Not sure if it will help, but I found this:

I am using the same command to upload an Image to Backendless but I get this error and the app terminated.

Unsupported value: <Backendless.BackendlessFile: 0x282f1e3e0> of type Backendless.BackendlessFile
*** Assertion failure in -[backendless_sdk.BackendlessWtiter writeValue:],
*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Unsupported value for standard codec’
*** First throw call stack:
(0x18489204c 0x19cf06f54 0x18614b6cc 0x10975c138 0x106e62850 0x106e62920 0x10975c7c0 0x109759890 0x106eab6d0 0x106e8addc 0x1069ccd94 0x10695c6e0 0x10695c7f0 0x185034b34 0x185045af8 0x184502914 0x184504660 0x184512b60 0x18484acd4 0x184804eac 0x1848183b8 0x1a01a838c 0x1871b86a8 0x186f377f4 0x104f6b984 0x106399a24)
libc++abi: terminating with uncaught exception of type NSException

  • thread #1, queue = ‘’, stop reason = signal SIGABRT
    frame #0: 0x00000001babd4964 libsystem_kernel.dylib__pthread_kill + 8 libsystem_kernel.dylib__pthread_kill:
    → 0x1babd4964 <+8>: b.lo 0x1babd4984 ; <+40>
    0x1babd4968 <+12>: pacibsp
    0x1babd496c <+16>: stp x29, x30, [sp, #-0x10]!
    0x1babd4970 <+20>: mov x29, sp
    Target 0: (Runner) stopped.
    Lost connection to device.

My codes in Flutter are these:
Uint8List file = await imageFile.readAsBytes();
await Backendless.files.saveFile(file, filePathName: ‘/StoreFiles/$ownerId/${imageFile.path.split(’/’).last}’).then((response) {
fileName = response.toString();

}).onError((error, stackTrace){
  print('savefile error: $error');

And when I want to just simply upload it it says:

[] Unhandled Exception: PlatformException(6002, Unable to write bytes into file /opt/backendless/repo/f16241ba-7a18-f7d0-ff2f-3f9e30c90900/files/StoreFiles/C69992E1-8298-49B3-AFF8-12515841899D, Unable to write bytes into file /opt/backendless/repo/f16241ba-7a18-f7d0-ff2f-3f9e30c90900/files/StoreFiles/C69992E1-8298-49B3-AFF8-12515841899D, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)

#2 UploadImageToBackend.uploadImageToBackendless (package:retailers/data/upload_image/upload_image.dart:17:5)

#3 (package:retailers/ui/view_select_image/show_image_widget.dart:73:17)

1 Like