尝试使用 RxFire 在 Google Cloud Storage 中上传大图像文件时出现错误:storage/object-not-found。
他们说在桶中找不到图像,但是当我检查时,我看到了!
我用小图像(可能是 100kb ......)进行了测试,效果很好。
但是尝试使用> 500kb的图像,不起作用......
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"}