Android QBCustomObject文件上传找不到资源错误

时间:2019-08-19 18:36:48

标签: file-upload custom-object quickblox-android

我正在尝试使用QBCustomObjectFiles上载文件,上载开始在log cat中显示进度,但是文件字段为null,并且响应抛出了这样的错误:“ {“ errors”:[“找不到资源”]} '

我在Quickblox管理面板上检查了我的Note Class,一切似乎都正常。我也检查了文件(方法参数中的字段),它不是null,如日志cat所示

public void uploadNote(Note note, File file, 
QBEntityCallback<QBCustomObjectFileField> callback, QBProgressCallback 
 progressCallback) {
    QBCustomObject customObject = new QBCustomObject();
    customObject.setClassName(Note.Contract.CLASS_NAME_NOTE);
    customObject.put(Note.Contract.COURSE_ID,note.getCourseId());
    customObject.put(Note.Contract.CATEGORY_ID,note.getCategoryId());
    customObject.put(Note.Contract.DESCRIPTION,note.getDescription());
    customObject.put(Note.Contract.TOPIC,note.getTopic());
    QBCustomObjectsFiles.uploadFile(file, customObject, "noteFile", progressCallback).performAsync(callback);

}

这是我的原木猫:

要求         开机自检https://api.quickblox.com/data/Note/null/file.json     标题         QuickBlox-REST-API-版本= 0.1.1         QB-SDK = Android 3.9.1         QB-令牌= 011a2bc55be67185d4d045d8b2d31     参数         field_name = noteFile     排队         POST https://api.quickblox.com/data/Note/null/file.json?field_name=noteFile

这是回应

      '{"errors":["The resource wasn't found"]}'

上传开始并显示进度,但是进度100之后,它将引发以上错误。

1 个答案:

答案 0 :(得分:0)

您应该使用 QBContent 而不是 QBCustomObjectsFiles 。示例:

QBContent.uploadFileTask(file, isPublic, tags, new QBProgressCallback() {
            @Override
            public void onProgressUpdate(int progressValue) {
                //some code for progress
            }
        }).performAsync(new QBEntityCallback<QBFile>() {
            @Override
            public void onSuccess(QBFile qbFile, Bundle params) {
                //some code for success upload
            }

            @Override
            public void onError(QBResponseException responseException) {
                //some code for error upload
            }
        });