Backendless Support
 
Answered

File from byte array file size

Greetings,

Why is it that when i upload a byte array (string) encoded as a Base64 string using POSTMAN the uploaded file is just 3KB in size but when i upload the same file from an android client using REST api the upload file size is a whooping 571KB?

Regards,

George

Leave a Comment

Comments (6)

photo
1

Hi, George.

1) What is your appId.

2) Please, provide small code snippet where you upload file.

photo
1

Hi Oleg,

  1. 850D233C-6AC2-244C-FFC5-ED60D85BFB00

I am making an asynchronous HTTP request to thebackendless server using RxJava and Retrofit as below

  1. @Headers("Content-Type: text/plain")
  2. @PUT("files/binary/photos/{fileName}?overwrite=true")
  3. Single<String> uploadFileFromByteArray(@Body String base64ImageString, @Path("fileName") String fileName);

Regards,

George

photo
1

Hi, George.

I've tried load file to your app with curl and with Android-sdk (Backendless.Files.upload( )) -- all files have the same size.

Also, i tried with simple URL/URLConnection, and i didn't make any encode/decode operations, they are not necessary.

Also pay attention to the "Content-Type" header. It should be like in documentattion:

https://backendless.com/docs/rest/doc.html#file-upload

photo
1

Am using SAVE BYTE ARRAY DOCUMENTATION, just below what you sent. See attached

photo
photo
1

Hi again George,

Did you compare the actual content of both files you uploaded via Postman and Java?

P.S.: Making the call using Retrofix?

Anton

photo
1

Hi Anton, i succeeded getting desired file sizes using the file-upload api as opposed to saving file from byte array.

You can close the topic.

Regards,

George