Support Topics Documentation Slack YouTube Blog

Upload files bitmap not available


(SnakeEyes) #1

Hello,

Is the upload of Bitmap using the Files service no longer available? The call is unrecognized and it only shows the upload of File or OutputStream


(Anton Govorushkin) #2

Hi @snakeeyes

Please show the code which is failing and the error you get (if there is such)

Anton


(SnakeEyes) #3

Bitmap bt = ((BitmapDrawable)ivMyPicture.getDrawable()).getBitmap();
Backendless.Files.upload(bt,CompressFormat.JPEG, 100, “pic.jpg”, “/user123”, AsyncCallback<BackendlessFile>() {
@Override
public void handleResponse(BackendlessFile response) {
updateUser(response.getFileURL());
}

@Override
public void handleFault(BackendlessFault fault) {
}
});


(Anton Govorushkin) #4

Hi @snakeeyes

I believe something is wrong either with the picture entity or somewhere else in your code, as I tried uploading pictures using bitmap approach. Used same method with the same number of arguments and everything works fine. Still didn’t receive any info regarding the error you are getting. Does the code go into the handleFault block? If so what does the error message say?

BTW you may want to download Android File uploading sample in Codegeneration tab of your Backendless app to verify that uploading API works as expected and to see how it’s implemented

Anton


(SnakeEyes) #5

Hi @Anton,
The error is that the upload method with bitmap is not recognized by the SDK.
Only the 8 upload methods from File and the 2 upload methods from Stream are available to be invoked from the SDK

I am using backendless version 5.0.2


(Vladimir Yalovy) #6

Hi @SnakeEyes

You use SDK for Android/Java?

https://backendless.com/docs/android/files_file_upload.html -> Android Only
Your bitmap - android.graphics.Bitmap?


(Anton Govorushkin) #7

That’s weird. I tried the same method as you did both with latest SDK (5.2.2) and with 5.0.2. In both cases method is recognized successfully. The signature is as following:

public BackendlessFile Backendless.Files.upload( 
                               android.graphics.Bitmap bitmap,
                               android.graphics.Bitmap.CompressFormat compressFormat,
                               int quality,
                               String remoteName,
                               String remotePath, AsyncCallback<BackendlessFile>() )

I’d recommend to try the following:

  1. Make sure you are passing android.graphics.Bitmap as a first argument
  2. Upgrade Backendless SDK to latest
  3. If 1 - true, try cleaning your gradle (rm -rf ~/.gradle/caches in your termianl) and Android project cache

Anton


(SnakeEyes) #8

Hello
I upgraded to the new release. It is still not there. Infact I went to your githib

and you can see that no method accept Bitmap in there


(Oleg Vyalyh) #9

Hi.
These methods now placed in class com.backendless.FilesAndroidExtra.
Use it, please, in such way: Backendless.Files.Android.upload().