Can someone write down a code of uploading pdf files to backendless using android

I have an upload button to upload CV here

btnUploadResults.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myFileIntent = new Intent(Intent.ACTION_GET_CONTENT);
                myFileIntent.setType("*/*");
                startActivityForResult(myFileIntent,30);
            }
        });


Then there is a code to upload that CV to backendless below

 @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        switch (requestCode){
            case 10:

                if(resultCode== RESULT_OK){
                    String path = data.getData().getPath();
                    //Toast.makeText(this, "path : " + path, Toast.LENGTH_SHORT).show();

                    String serverPath = "https://backendlessappcontent.com/8E3F66A3-828B-5C65-FF7F-E70047E63700/8FFDA82D-FE6B-FFDB-FF1C-41BA8ADDD400/files/Users+CV";

                    Backendless.Files.upload(new File(path), serverPath, true, new AsyncCallback<BackendlessFile>() {
                                @Override
                                public void handleResponse(BackendlessFile response) {

                                    Toast.makeText(StudentRegistration.this, "PDF SAVED TO SERVER", Toast.LENGTH_SHORT).show();
                                }

                                @Override
                                public void handleFault(BackendlessFault fault) {
                                    Toast.makeText(StudentRegistration.this, fault.getMessage(), Toast.LENGTH_SHORT).show();
                                }
                            }
                    );

                }

                break;

What am I doing wrong because the CV cannot be saved??

Hello @maipato_monyeke

You are incorrectly specifying the path where the image should be saved. Change

String serverPath = “https://backendlessappcontent.com/8E3F66A3-828B-5C65-FF7F-E70047E63700/8FFDA82D-FE6B-FFDB-FF1C-41BA8ADDD400/files/Users+CV”;

to

String serverPath = “folder_name”;

Regards,
Inna

@Inna_Shkolnaya I did use the server path but it still is not working

Hi @maipato_monyeke

First at all, the requestCode inside startActivityForResult() method and inside switch statement should be the same. In your case, there are two different values (30 and 10).
Then, second parameter inside Backendless.Files.upload should be the server path to the folder you want to save the file in. So, if you have UsersCV folder in your root directory, the value should be "UsersCV", without https://....

Best Regards,
Maksym