Backendless Support
 
Answered

REST equivalent of Bitmap File Upload

Greetings,

What is the REST equivalent of the SDK code below for uploading a Bitmap. It's not clear in the REST documentation. If possible avoiding a base64 String conversion.

  1. public void Backendless.Files.upload(
  2. android.graphics.Bitmap bitmap,
  3. android.graphics.Bitmap.CompressFormat compressFormat,
  4. int quality,
  5. String remoteName,
  6. String remotePath,
  7. AsyncCallback<BackendlessFile> responder ) throws Exception

I would really appreciate a simple curl illustration.

Regards,

George

Leave a Comment

Comments (4)

photo
1

Hi George

here is link to the docs and example

https://backendless.com/docs/rest/doc.html#file_save_files_from_byte_arrays

but with base64

Why you don't want to encode it base64?

Regards, Vlad

photo
1

Hi Vladimir,

base64 results in a bigger file size, 468.00 KB+ for a thumbnail.

In the theory section it is indicated:

  1. Request headers:
  2. Content-Type: multipart/form-datauser-token: optional value obtained as a result of the login operation.

While in the curl example immediately following the theory above you used text/plain as the Content-Type. Which one is to be used?

Example:

  1. curl -H Content-Type: text/plain
  2. -X PUT \
  3. -v https://api.backendless.com/XXXX-XXXX-XXXX/ZZZZ-ZZZZ-ZZZZ/files/binary/testFolder/savedNote.txt?overwrite=true"; \
  4. -d bXkgY29vbCBub3Rl

photo
1

ok, try this:

  1. curl 'https://api.backendless.com/APP_ID/API_KEY/files/my-folder/my-img.jpg?overwrite=true' -F 'files[]=@/Absolute/Path/To/file.jpg'

photo
1

Hi Vladimir, i succeeded, thanks.

You can close the topic.

Regards,

George

photo