sdk-for-flutter icon indicating copy to clipboard operation
sdk-for-flutter copied to clipboard

🐛 Bug Report:Flutter web app, createFile() not uploading the whole file

Open DobreRadu opened this issue 3 years ago • 12 comments

👟 Reproduction steps

I am using flutter_dropzone: ^3.0.5 to load the file,in onDrop: (dynamic ev) I added

  List<int> resultValue = [];
  await for (List<int> lista in controller.getFileStream(ev)) {
                                    resultValue = resultValue + lista;
                                  }

to create to create a List of the file.Using the createFile from appwrite sdk loads the image on the server(bigger than 5MB),it displays the actual size but when downloading it gives me part of the image(I estimate 5MB of data because of the test I did,where an image of 6Mb was not showing like 1/6 of the bottom part) and opening in New Window gives me a part of image then a link.

Future<File> result = storage.createFile(
                                    bucketId: '62fb5a75577eb6912acd',
                                    fileId: 'unique()',
                                    file: InputFile(
                                        filename: '${ev.name}',
                                        bytes: resultValue),
                                  );

Don't believe is from the flutter_dropzone,it works as it gives me the image as List,it actually loads all the bytes needed. Flutter doctor output:

[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1889], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.5)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.70.2)
[√] Connected device (3 available)
[√] HTTP Host Availability

👍 Expected behavior

The image should be fully displayed.

👎 Actual Behavior

Part of it is showing.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Flutter web

🧱 Your Environment

SDK is 6.0.0 and Server is v:0.15.3.402.

👀 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?

DobreRadu avatar Aug 18 '22 21:08 DobreRadu

I also tried to upload a file using the playground-for-flutter, but the uploaded file seemed to be invalid after downloading it again.

stnguyen90 avatar Aug 18 '22 21:08 stnguyen90

I also tried to upload a file using the playground-for-flutter, but the uploaded file seemed to be invalid after downloading it again.

Yes upload works in flutter,gives no error,but downloading it from server or displaying in the 'New Window' option doesn't work.

DobreRadu avatar Aug 18 '22 21:08 DobreRadu

@DobreRadu I got it working without issues, here's the code I'm using https://github.com/appwrite/playground-for-flutter/tree/feat-upgrade-latest

Let me know if this works. (I'm using getFileData instead of getFileStream) to get the file bytes.

lohanidamodar avatar Aug 24 '22 04:08 lohanidamodar

I will try soon,thanks.

DobreRadu avatar Aug 24 '22 05:08 DobreRadu

@DobreRadu I got it working without issues, here's the code I'm using https://github.com/appwrite/playground-for-flutter/tree/feat-upgrade-latest

Let me know if this works. (I'm using getFileData instead of getFileStream) to get the file bytes.

Tried using getFileData,still doesn't work. Future<File> result = storage.createFile( bucketId: dotenv.env['APPWRITE_BUCKET'] ?? '', fileId: 'unique()', file: InputFile( filename: '${ev.name}', bytes: await dropFileController .getFileData(ev)), );

DobreRadu avatar Aug 24 '22 18:08 DobreRadu

@DobreRadu, would you be able to provide the original file you're trying to upload?

stnguyen90 avatar Aug 24 '22 18:08 stnguyen90

unknown

DobreRadu avatar Aug 24 '22 18:08 DobreRadu

@DobreRadu, would you be able to provide the original file you're trying to upload?

Did it work ?

DobreRadu avatar Aug 24 '22 20:08 DobreRadu

@DobreRadu, I was able to reproduce, but @lohanidamodar will need to test to see if he can reproduce.

stnguyen90 avatar Aug 24 '22 20:08 stnguyen90

Oh ok,thanks.

DobreRadu avatar Aug 24 '22 20:08 DobreRadu

BTW how you can upload big size of files? I can't any upload if the size bigger than 5mb. I don't understand the content-range details with dart

grisoftumut avatar Sep 07 '22 15:09 grisoftumut

@grisoftumut, thanks for your question, but please either create a new issue or join us on Discord. It can be confusing to talk about different topics in one issue.

stnguyen90 avatar Sep 07 '22 18:09 stnguyen90

@DobreRadu can you test from this branch? https://github.com/appwrite/sdk-for-flutter/tree/fix-flutter-web-chunked-upload

lohanidamodar avatar Nov 25 '22 05:11 lohanidamodar

You mean updating to appwrite 8.1.0?

DobreRadu avatar Nov 25 '22 15:11 DobreRadu

@DobreRadu I mean using it from fix-flutter-web-chunked-upload branch on of the SDK

lohanidamodar avatar Nov 27 '22 05:11 lohanidamodar

Hello,tested with the appwrite 1.0 and sdk 8.1.0, it's working,thanks!

DobreRadu avatar Feb 09 '23 08:02 DobreRadu

Actually not,the photo given in this thread is still not working...it's giving me an URL. I tested with a 10mb photo and is working.

DobreRadu avatar Feb 09 '23 08:02 DobreRadu

Actually not,the photo given in this thread is still not working...it's giving me an URL. I tested with a 10mb photo and is working.

Are you sure? Because I ran multiple successful tests with this photo itself and other files as well, and the issue was mis-calculation which was resolved.

lohanidamodar avatar Feb 24 '23 08:02 lohanidamodar

Yes I am sure,maybe I use a different version or something then...Thanks for the help !

DobreRadu avatar Feb 24 '23 16:02 DobreRadu