我尝试使用QBContent类将图片上传到QuickBlox。总是发现错误:
" com.quickblox.core.exception.QBResponseException:连接失败。请检查您的互联网连接。"
但所有其他请求都可以。 这是我的代码:
String imagePath = "";
Uri targetUri = data.getData();
if (data.toString().contains("content:")) {
imagePath = getRealPathFromURI(targetUri);
} else if (data.toString().contains("file:")) {
imagePath = targetUri.getPath();
} else {
imagePath = null;
}
file = new File(imagePath);
QBFile qbfile = new QBFile();
qbfile.setName("avatar");
qbfile.setPublic(true);
qbfile.setContentType(ContentType.getContentType(file));
QBContent.createFile(qbfile).performAsync(new QBEntityCallback<QBFile>() {
@Override
public void onSuccess(QBFile file1, Bundle params) {
Log.i("kek", ">>> File" + file1.toString());
fileObjectAccess = file1.getFileObjectAccess();
String paramss = fileObjectAccess.getParams();
QBContent.uploadFileTask(file, true, null, new QBProgressCallback() {
@Override
public void onProgressUpdate(int progress) {
}
}).performAsync( new QBEntityCallback<QBFile>() {
@Override
public void onSuccess(QBFile qbFile, Bundle params) {
qbFile.getName();
}
@Override
public void onError(QBResponseException error) {
error.printStackTrace();
}
});
}
@Override
public void onError(QBResponseException errors) {
errors.printStackTrace();
}
});