我在将图像网址存储到实时数据库中时遇到问题。它存储一个与存储中图像的 url 无关的 url。
private void uploadFile (){
if (mImageUri != null){
StorageReference fileReference = mStorageRef.child(System.currentTimeMillis()
+ "." + getFileExtension(mImageUri));
uploadProgressBar.setVisibility(View.VISIBLE);
uploadProgressBar.setIndeterminate(true);
mUploadTask = fileReference.putFile(mImageUri)
.addOnSucessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
uploadProgressBar.setVisibility(View.VISIBLE);
uploadProgressBar.setIndeterminate(false);
uploadProgressBar.setProgress(0);
}
},500);
Toast.makeText(AddProductActivity.this, "Product is added successfully!", Toast.LENGTH_SHORT).show();
Product product = new Product(productName.getText().toString()
,productDescription.getText().toString()
,price.getText().toString()
,taskSnapshot.getUploadSessionUri().toString()
,oldPrice.getText().toString()
}
})
当我从 imageUrl 字段复制存储的 url 并尝试查看它是否会显示图像时,我收到此文本错误:
无效的请求。X-Goog-Upload-Command 标头丢失。
陪伴而非守候
相关分类