Cant upload using director upload

Just now i cant now upload using director upload,
is anyone feeling the same? Im testing my app Dio flutter, before it worked fine, but suddenly, not working anymore, is there any problem on cloudflare stream server? or just me

It’s working fine for me.

hmm, yes the image in my app more like not finish upload or something, im using flutter package called Dio, with header of ‘Accept-Ranges’: ‘bytes’ , the upload never finished in my app, but after some minutes passed, the image showed in the cloudflare images dashboard

Could you share some of the code that you have carrying this function out? I might be able to help find if there’s an issue with it. Not sure if this is acceptable to do but technically its a community forum so I think so!

1 Like

okay , here it goes:

       FormData data = FormData.fromMap({
                       "file": await MultipartFile.fromFile(
                        imageFile.path,
                        filename: fileName,
                      ),
                      });

             try {
                      setState(() {
                        loadingState = true;
                        message = "";
                      });
                      var client = Dio();
                      final response = await client.put(uploadUrl,
                          options: Options(
                            headers: {'Accept-Ranges': 'bytes'},
                          ),
                          data: data,
                          onSendProgress: (int sent, int total) {
                        double percentage = sent / total;

                        setState(() {
                          progress = percentage;
                        });
                      });

                      var dataResponse = response.data();
                      List<String> variants =
                          dataResponse["result"]["variants"];

                      print(variants.toString());
                      setState(() {
                        message = "Success upload";
                        loadingState = false;
                      });
                    } catch (e) {
                      message = e.toString();
                    }
                  }

the application still waiting dio.put to be finished, and never finished, before, i mean before today everything worked fine, until just couple hours ago

My first thought is that you’re using put rather than post. This ought to be post when you’re uploading an image.

Whats the reasoning behind the 'Accept-Ranges': 'bytes' header you’re sending?

to get the progress report from Dio,to smooth the process, now it worked when im deleting the headers bytes and change to post, i wonder why before it worked but now not,
after deleting the headers and change to post, it worked now, but now i cant show the progress :slightly_frowning_face:

It is interesting that put was working. How long are the images taking to upload about? Progress has always been a tough one. Personally, the upload is fast enough that just showing the an image is uploading is enough. I have multiple images uploading in batch and show progress based on completed images out of total images to upload.

Since Cloudflare’s documentation doesn’t explicitly say they support the Accept-Range header from what I can see, its probably best to steer clear of it. Things can be unstable otherwise as you’ve seen.

Glad you were able to get the upload working! :slight_smile:

This topic was automatically closed after 15 days. New replies are no longer allowed.