图像未上传到Firebase实时数据库,其他值未上传

问题描述 投票:0回答:1
private void updateproductInfo(String date, String pid, String time, String description, String categoryName, String name, String price , String location ,String img1 ,String img2,String img3) {

    final StorageReference imageFilePath = ProductImagesRef;

    for (int uploadCount = 0; uploadCount<ImageList.size(); uploadCount++){
        Uri IndividualImage= ImageList.get(uploadCount);
        final StorageReference ImageName = imageFilePath.child(pname);
        final int finalUploadCount = uploadCount;
        ImageName.putFile(IndividualImage).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                ImageName.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                    @Override
                    public void onSuccess(Uri uri) {
                        String url = String.valueOf(uri);
                        DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("ProductImages").child(productkey);
                        if (finalUploadCount==0){
                            url1 = String.valueOf(uri);
                        }
                        else if (finalUploadCount == 1){
                            url2 = String.valueOf(uri);
                        }
                        else if (finalUploadCount == 2){
                            url3 = String.valueOf(uri);
                        }
                    }
                });
            }
        });
    }

    Product product = new Product(date,pid,time,description,categoryName,name,price,location,img1,img2,img3);
    FirebaseDatabase.getInstance().getReference("Products").child(productkey).setValue(product).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()){
                Toast.makeText(getApplicationContext(),"User Details Updated Successfully",Toast.LENGTH_LONG).show();
            }
            else {
                Toast.makeText(getApplicationContext(),task.getException().getMessage(),Toast.LENGTH_LONG).show();
            }
        }
    });

}

图像未上传到Firebase实时数据库,其他值也已上传。图片未上传到Firebase实时数据库,其他值也已上传。图片未上传到Firebase实时数据库,其他值也已上传。请尽快提供帮助。

java android firebase firebase-realtime-database firebase-storage
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.