【问题标题】:Android QBCustomObject file uploading The resource wasn't found errorAndroid QBCustomObject 文件上传资源未找到错误
【发布时间】:2019-12-24 23:57:53
【问题描述】:

我正在尝试使用 QBCustomObjectFiles 上传文件,上传开始在 log cat 中显示进度,但文件字段为 null 并且响应抛出类似这样的错误 '{"errors":["The resource was not found"]} '

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

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 排队 发布https://api.quickblox.com/data/Note/null/file.json?field_name=noteFile

这是回应

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

上传开始并显示进度,但在进度 100 后会抛出上述错误。

【问题讨论】:

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


    【解决方案1】:

    您应该使用 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
                }
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 2016-03-31
      相关资源
      最近更新 更多