Skip to content
Back

Cannot upload files to storage

  • 0
  • Self Hosted
  • Flutter
  • Storage
hernik
9 Oct, 2023, 13:53
TypeScript
UploadService().pickFile().then((file) async {
      if (file != null) {
        Logger().i(file.files.single.name);

        // file info
        String fileName = "${DateTime.now().toString()}-${file..names.first}";
        Uuid uuid = const Uuid();
        String fileId = uuid.v4();

        var finFile = InputFile.fromPath(
          path: file.files.single.path!,
          filename: fileName,
        );

        try {
          storage
              .createFile(
            bucketId: AppSettings.storageBucketId,
            fileId: fileId,
            file: finFile,
            onProgress: (p0) {
              Logger().d(p0);
            },
          )
              .catchError((e) {
            Logger().e(e);
          });
        } catch (e) {
          Logger().e(e);
        }
      } else {
        setState(() {
          showUploadingScreen = false;
        });
      }
    });
TL;DR
User is experiencing an issue with uploading files to storage. They are receiving a 'SIGPIPE' error and the nginx container logs the same error. They have tried testing against Appwrite directly without nginx and it works fine. The file size is 7.4 MiB and the code being used is provided. The issue seems to be related to the 'content-length' header, which exceeds the package max length. A solution is not provided in the support thread.
hernik
9 Oct, 2023, 13:54

Using packages file_picker and uuid

Drake
9 Oct, 2023, 16:52

interesting...can you check the file size with this?

TypeScript
      final iofile = File(file.path!);
      final size = await iofile.length();
      print(size);
hernik
9 Oct, 2023, 17:26

A file shown as 7.4 MiB in my file explorer prints 7735676. Appwrite docker container logs WARNING Port_onRead_http() (ERRNO 7102): Request Entity Too Large: header-length (1621) + content-length (40611618) is greater than the package_max_length(6291456) from session#3099 on 0.0.0.0:80

Drake
9 Oct, 2023, 17:44

please add the code that i shared

hernik
9 Oct, 2023, 17:48

I did, and it printed 7735676

Drake
9 Oct, 2023, 17:49

oh sorry. i was confused because you said file explorer

hernik
9 Oct, 2023, 17:52

My bad, I meant that in my file explorer the file shows up as 7.4 MiB and that it checks out comparing it to the value printed by the code you posted 😅

Drake
9 Oct, 2023, 17:57

can you use the debugger and check if it's reaching here? https://github.com/appwrite/sdk-for-flutter/blob/44533ca07c20323705d97934cb2229c8b7960847/lib/src/client_io.dart#L296 Then check the value of that headers['content-range']

hernik
9 Oct, 2023, 17:59

Will give it a try

hernik
9 Oct, 2023, 18:02

The debugger's Network section says the content-length header for the file upload request is 40611618

hernik
9 Oct, 2023, 18:03

I sent the same file as before by the way

Drake
9 Oct, 2023, 18:30

this happens later.

Drake
9 Oct, 2023, 18:31

im curious about this section

hernik
9 Oct, 2023, 18:46

The exception is thrown at that line, so I cannot get the headers after the call

hernik
9 Oct, 2023, 18:49

oh wait no it has content range

hernik
9 Oct, 2023, 18:49

content range is bytes 0-5242879/7735676

Drake
9 Oct, 2023, 18:50

So this is good...we should only be sending 5MB from the SDK...

Drake
9 Oct, 2023, 18:51

Can you check the size of chunk?

hernik
9 Oct, 2023, 18:54

Goes up to 5242879

Drake
9 Oct, 2023, 18:55

Ya this seems all right ...can you test directly against Appwrite without nginx?

hernik
9 Oct, 2023, 18:56

Will try

hernik
9 Oct, 2023, 19:01

chunk and content-range is the same, appwrite SDK throws an appwrite exception with SIGPIPE and appwrite docker container logs the same error as before

Drake
9 Oct, 2023, 19:03

sigpipe?? that's weird...

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more