0

I am using the function below to upload a file.

File fileResult = await file.writeAsBytes(byte, mode: FileMode.append);

I test 2 cases by

  1. Uploaded 1.png in the empty folder.
  2. Uploaded 1.png in the folder that already has 1.png.

These results are the same! But case 2 can't upload because this file name already exists and I use the FileMode.append method. The fileResult.isAbsolute is always false I don't know why.

I can check by using the await file.exists() before uploading or using a unique file name. But I want to know how to check the upload by using _.writeAsBytes() is a success or not.

  • Is your `file` object a reference the already existing `1.png` file? Or is the `1.png` created, then uploaded to that directory? – Apealed Nov 03 '22 at 21:34
  • The situation looks like the `1.png` already exists in the folder. Assume 2 users send an image from the flutter app simultaneously and these images have the same name. When these images are sent to the dart server, The server will upload an image of the first user. Then upload an image of the second user but this was not successful. I want a signal that tells me this upload was not a success. – Sittiphan Sittisak Nov 04 '22 at 02:08

0 Answers0