Firesore不会从数组中添加图片URL

时间:2018-10-09 03:53:35

标签: android firebase google-cloud-firestore

im通过for循环将图像URL添加到数组中,但是当我尝试将其上传到DB时,它将无法工作! 这是代码。

for (int i = 0; i < selectedImages.size(); i++) { 
      // List imgUrl=new ArrayList<>(fileNameList); 
      Uri fileUri= Uri.fromFile(new File(String.valueOf(selectedImages.get(i)))); 
      Log.v("UriLog", String.valueOf(fileUri)); 
      StorageReference reference = mstorageReference.child("pictures").child(System.currentTimeMillis() + ".jpg" );
      reference.putFile(fileUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
               Toast.makeText(getActivity(), "Upload Success!",Toast.LENGTH_LONG).show();

                assas.add(taskSnapshot.getMetadata().getReference().getDownloadUrl().toString());

                // CollectionReference pics = db.collection("Ad details").document().collection("pics_src");
           //   pics.add(Arrays.asList(submit_ad));

            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Toast.makeText(getActivity(), e.getMessage(),Toast.LENGTH_SHORT).show();
            }
        });


    }

0 个答案:

没有答案