1
votes

My problem is I am using QBContent.uploadFileTask(file, true, null, new QBEntityCallback() to upload the file to QuickBlox. But I am landing on onError(List list). Check pictures please.

  1. This is I get in OnError Method: enter image description here
  2. Showing in Logcat: enter image description here

    Here is my Code:

    protected void startLoadAttachAudio(final File file) { Handler h = new Handler(Looper.getMainLooper()); h.post(new Runnable() { public void run() {

            QBContent.uploadFileTask(file, true, null, new QBEntityCallback<QBFile>() {
                @Override
                public void onSuccess(QBFile qbFile, Bundle bundle) {
                    System.out.println("Success");
                }
    
                @Override
                public void onSuccess() {
                    System.out.println("Success2");
                }
    
                @Override
                public void onError(List<String> list) {
                    System.out.println("Failed.");
    
                }
            });
        }//end of run
    }); //end of handler
    

    }

2
please post full log from logCat to gist.github.com for better understanding your issue. Why do use old QuickBlox Android SDK? - Valentyn Tereshchenko
you use very old version of QuickBlox Android SDK (it can contain issues, which were fixed in latest versions), please use latest version for check your issue. - Valentyn Tereshchenko
Thanks for your response - Rashid Afzaal

2 Answers

1
votes

You can use library for upload file, i am using android async http. For example:

public void UploadFile(CarrierFileInformation carrierFileInformation)
{
    String path = carrierFileInformation.GetSaveDir();
    File file = new File(path);
    if(!file.exists())
    {
        this.uploadedFile = true;
        Toast.makeText(this.activity, this.activity.getResources().getString(R.string.not_found_file), Toast.LENGTH_LONG).show();
        return;
    }
    String link = Settings.DOMAIN + MethodNames.UPLOAD_FILE;
    RequestParams requestParams = new RequestParams();
    try
    {
        requestParams.put(FieldNames.UPLOAD_FILE, file);
        requestParams.put(FieldNames.ORDER_ID, carrierFileInformation.GetOrderId());
        requestParams.put(FieldNames.TEST_ID, carrierFileInformation.GetTestId());
        requestParams.put(FieldNames.TEST_DETAIL_ID, carrierFileInformation.GetTestDetailId());
        requestParams.put(FieldNames.FLAG, carrierFileInformation.GetFlag());
    }
    catch (FileNotFoundException e)
    {
        e.printStackTrace();
    }
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    asyncHttpClient.post(link, requestParams, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            Log.e("t", "işlem tamam");
            uploadedFile = true;
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
            uploadedFile = false;
        }
    });
}

requestParams using for send params your webservice, file you know your file. you can edit my function.

In build.gradle you have to add this code compile 'com.loopj.android:android-async-http:1.4.9' in dependices bloc then sync.

0
votes

I solved it myself by Updating the SDK version of Quickblox