【发布时间】:2020-02-12 10:57:05
【问题描述】:
我正在将图像上传到 Firebase 存储,但此错误不断出现
E/StorageException:发生了 StorageException。 对象在该位置不存在。 代码:-13010 HttpResult:404 E/StorageException:{“错误”:{“代码”:404,“消息”:“未找到。无法获取对象”,
“状态”:“GET_OBJECT”}} java.io.IOException: { "error": { "code": 404, "message": "Not Found. could not get object", "status": "GET_OBJECT" }}
这是我的代码:
StorageReference postimage_path=firebaseStorage.child("Post Image").child(random+".jpg");
postimage_path.putFile(newposturi);
postimage_path.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if(task.isSuccessful())
{
Uri download_url=task.getResult();
Map<String,String> postmap=new HashMap<>();
postmap.put("download url",download_url.toString());
postmap.put("Description",post);
postmap.put("user_id",currentuser);
postmap.put("timestamp",""+FieldValue.serverTimestamp());
postfirestore.collection("Posts").add(postmap).addOnCompleteListener(new OnCompleteListener<DocumentReference>() {
@Override
public void onComplete(@NonNull Task<DocumentReference> task) {
if(task.isSuccessful()){
Toast.makeText(PostActivity.this, "Post Successful", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(PostActivity.this,MainActivity.class);
startActivity(intent);
finish();
}
else{
String error=task.getException().getMessage();
Toast.makeText(PostActivity.this, "Error while Posting :"+error, Toast.LENGTH_SHORT).show();}
newpostprogress.setVisibility(View.INVISIBLE);
}
});
}
【问题讨论】:
标签: android firebase google-cloud-storage firebase-storage