Back

[SOLVED] Empty file passed to the endpoint. (400)

  • 0
  • Flutter
joeyouss
17 Feb, 2023, 10:00

cool, let me take a look with this

TL;DR
User is experiencing an error of "Empty file passed to the endpoint. (400)" while using the storage createFile() method with bytes for InputFile. They receive a response from `readBytes()` but not from the request. They are unsure of what to send and are not trying to use a cloud function. They have tried multiple images from different sources but still get the empty file error. Someone suggests removing "%22" from the URL as a potential solution.
Bender
17 Feb, 2023, 10:09

ty!

joeyouss
17 Feb, 2023, 10:38

Can you try removing “%22” from your URL? I am saying this since removing it shows me the image else it does not

Bender
17 Feb, 2023, 10:39

i tried that too, i have tried multiple images from different sources, even from own bucket, no cors problem, and the empty file error persists

bradleySchofield
17 Feb, 2023, 10:42

could you send me a zip or tar.gz of the function files?

Bender
17 Feb, 2023, 10:54

I am unsure what to send, and I am not trying to use a cloud function, I am basically trying to use this the storage createFile() method with bytes for InputFile as required for web.

bradleySchofield
17 Feb, 2023, 10:56

I've just noticed, your trying to readBytes a url but shouldn't you be making a network request there?

bradleySchofield
17 Feb, 2023, 10:56

then taking the body and moving it into a buffer?

Bender
17 Feb, 2023, 10:58

Future<Uint8List> readBytes(Uri url, {Map<String, String>? headers}) Type: Future<Uint8List> Function(Uri, {Map<String, String>? headers})

package:http/http.dart

Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a list of bytes.

Bender
17 Feb, 2023, 10:58

And I do get bytes back.

bradleySchofield
17 Feb, 2023, 10:59

Hm, I see

bradleySchofield
17 Feb, 2023, 10:59

allow me to find a colleague who might have more familiarity with flutter

bradleySchofield
17 Feb, 2023, 10:59

I personally haven't used it alot

Bender
17 Feb, 2023, 11:00

TY! I do not, however, think it's a problem with flutter. But that might be so.

bradleySchofield
17 Feb, 2023, 11:00

Do you receive a response from the request?

Bender
17 Feb, 2023, 11:01

I do, from readBytes()

bradleySchofield
17 Feb, 2023, 11:03

what about the appwrite function?

bradleySchofield
17 Feb, 2023, 11:03

Do you get a response from that?

Bender
17 Feb, 2023, 11:03

I get Empty file passed to the endpoint. (400)

dlohani
17 Feb, 2023, 11:42

@Bender I found the problem, we should have a better documentation, because you are providing the bytes, you also need to provide filename parameter otherwise the file will not be received. please include filename parameter in the InputFile along with bytes and it should work

Bender
17 Feb, 2023, 11:48

now it works, but i did provide the name at some point. baffled, but great it works.

Bender
17 Feb, 2023, 11:48

TY!

dlohani
17 Feb, 2023, 11:48

TY for running into this error, now we can fix in the SDK with some assertions 😄

dlohani
17 Feb, 2023, 11:49

Please mark it as solved by editing the title [SOLVED] ...

Bender
17 Feb, 2023, 11:51

[SOLVED] Empty file passed to the endpoint. (400)

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