Problems with File upload API

In the console am seeing a root/web folder, but when I copy the URL of a file in this folder I get files/web. I tried using the upload API to upload a bitmap to this folder but I can’t see the bitmap and I have reached handleResponse without errors. What path should I use in the API call? What am I missing?

Hello @Nkekere_Tommy_Minimann

Just use “web” for the path. If the problem is reproducible, please provide your APT ID and the code snippet that you use to upload the file.

Regards,
Inna

Am calling this function

public static void uploadPic(Bitmap photo, String name, String path){
Backendless.Files.Android.upload( photo, Bitmap.CompressFormat.PNG, 100, name, path,
new AsyncCallback()
{
@Override
public void handleResponse( final BackendlessFile backendlessFile )
{
Timber.i(“picture uploaded %s%s”, path,name);
}

                @Override
                public void handleFault( BackendlessFault backendlessFault )
                {
                    Timber.e("picture failed to upload %s", backendlessFault.getMessage());
                }
            });
}

path: "https://backendlessappcontent.com/F8C6F7F3-E6B2-BCC8-FFF7-2CA63032F900/FBDC30B9-7D28-46AA-BF42-88270EC615FD/files/web/

APP ID: F8C6F7F3-E6B2-BCC8-FFF7-2CA63032F900/FBDC30B9-7D28-46AA-BF42-88270EC615FD

I’ve tried such a code with you app, and it works.

File f = Paths.get("test_file").toFile();
Backendless.Files.uploadFromStream( new FileOutputStreamRouter( f, new UploadCallback()
{
  @Override
  public void onProgressUpdate( Integer progress )
  {
    System.out.println("Upload progress: " + progress);
  }
} ), "fileName.txt", "", true );

Could you try such approach from your side ?

Am sorry but I really can’t figure out how to apply this in my case. Am uploading a bitmap, and your code doesn’t specify the remote directory where the bitmap will be uploaded to.

The 3rd argument in the uploadFromStream method is the remote path:


In the example above, the value is "", which means the data from the stream will be uploaded and saved in a file in the remote root directory.

Mark

@Nkekere_Tommy_Minimann

Here is a working code which I actually just tried again for bitmap uploads

        Bitmap bmp =((BitmapDrawable)ivMyPicture.getDrawable()).getBitmap();
        Backendless.Files.Android.upload(bmp, Bitmap.CompressFormat.PNG, 100, "test.png", "web", new  AsyncCallback(){

            @Override
            public void handleResponse(Object response) {
                Log.d(GlobalVar.TAG, "succes");
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                Log.d(GlobalVar.TAG, "failed");
            }
        });

The uploaded was successfull and went to the “web” folder under files. Run this sample and if you face issues, check that your bitmap object is actually a valid bitmap

Thanks guys, I got it. Both approaches work. In the previous one I initially missed the remote folder.