提供下面的信息有助于更快地解决问题:
1、问题详情:
上传文件失败,报空指针
2、SDK 版本号:
8.2.4
3、相关代码片段:
String fileName = images.getOriginalFilename();
LCFile file = new LCFile(fileName, images.getBytes());
file.saveInBackground().subscribe(new Observer() {
@Override
public void onSubscribe(Disposable disposable) {}
@Override
public void onNext(LCFile file) {
System.out.println("文件保存完成。URL:" + file.getUrl());
}
@Override
public void onError(Throwable throwable) {
// 保存失败,可能是文件无法被读取,或者上传过程中出现问题
}
@Override
public void onComplete() {}
});
4、相关日志:
(打开日志的方法:在 LeanCloud.initialize() 之前调用 'LeanCloud.setLogLevel(LCLogger.Level.DEBUG); ')
cn.leancloud.LCException: java.lang.NullPointerException
at cn.leancloud.upload.QiniuSlicingUploader.execute(QiniuSlicingUploader.java:109) ~[storage-core-8.2.4.jar:?]
at cn.leancloud.upload.FileUploader.execute(FileUploader.java:42) ~[storage-core-8.2.4.jar:?]
at cn.leancloud.LCFile$3.apply(LCFile.java:562) [storage-core-8.2.4.jar:?]
at cn.leancloud.LCFile$3.apply(LCFile.java:550) [storage-core-8.2.4.jar:?]
at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:57) [rxjava-2.2.21.jar:?]