我收到了一个错误:当试图使用RxFire在中上传一个大的图像文件时,没有找到存储/对象。
他们说这张照片不是在桶里找到的,但是当我检查的时候,我看到了它们!
我用小图像进行测试(可能是100.)效果很好。
但是尝试了超过500‘t的图像,不起作用.
upload$
.pipe(
switchMap((event: any) => {
const name = Math.random().toString(36).substring(5);
const blob = event.target.files[0];
const type = blob.type.replace('image/', '');
const ref = storage.ref(`uploads/test/${name}.${type}`);
return put(ref, blob);
}),
map(snapshot => snapshot),
filter(snapshot => snapshot.totalBytes === snapshot.bytesTransferred),
mergeMap(snapshot => getDownloadURL(snapshot.ref))
)
.subscribe(url => {
console.log('Results', url)
}, (error) => {
// ERROR HERE
console.log('error', error)
})预期结果:上传大图片
实际结果:误差
Uncaught t {code_: "storage/object-not-found", message_: "Firebase .
Storage: Object 'uploads/test/7xpbilmb.jpeg' does not exist.",
serverResponse_: "{↵ "error": {↵ "code": 404,↵ "message":
"Not Found. Could not get object"↵ }↵}", name_: "FirebaseError"}发布于 2019-06-03 22:18:23
你可以两全其美。
这应该足够你拿到你的downloadURL了。如果您希望跟踪可观察到的上载进度,请使用下面的代码:
task.percentageChanges().subscribe(progress => {
console.log('upload progress: ', progress);
if (res >= 100) {
// HOORAY!
}
});https://stackoverflow.com/questions/54278902
复制相似问题