How to use getdownloadurl in recent versions?












0















                Uri downloaduri=taskSnapshot.getDownloadUrl();//here i cant use getdownloadurl() function
DatabaseReference new_prod=db.push();
new_prod.child("product name").setValue(prod_name);
new_prod.child("product price").setValue(prod_price);
new_prod.child("available stock").setValue(prod_quan);
new_prod.child("product image").setValue(downloaduri);
pd.dismiss();//fragments code


I was unable to use getdownloadurl .I have already stored image in the firebase storage.Is it the fragment that is restricting the use of getdownloadurl? My motive is to make a query to store in firebase.please help me.










share|improve this question





























    0















                    Uri downloaduri=taskSnapshot.getDownloadUrl();//here i cant use getdownloadurl() function
    DatabaseReference new_prod=db.push();
    new_prod.child("product name").setValue(prod_name);
    new_prod.child("product price").setValue(prod_price);
    new_prod.child("available stock").setValue(prod_quan);
    new_prod.child("product image").setValue(downloaduri);
    pd.dismiss();//fragments code


    I was unable to use getdownloadurl .I have already stored image in the firebase storage.Is it the fragment that is restricting the use of getdownloadurl? My motive is to make a query to store in firebase.please help me.










    share|improve this question



























      0












      0








      0








                      Uri downloaduri=taskSnapshot.getDownloadUrl();//here i cant use getdownloadurl() function
      DatabaseReference new_prod=db.push();
      new_prod.child("product name").setValue(prod_name);
      new_prod.child("product price").setValue(prod_price);
      new_prod.child("available stock").setValue(prod_quan);
      new_prod.child("product image").setValue(downloaduri);
      pd.dismiss();//fragments code


      I was unable to use getdownloadurl .I have already stored image in the firebase storage.Is it the fragment that is restricting the use of getdownloadurl? My motive is to make a query to store in firebase.please help me.










      share|improve this question
















                      Uri downloaduri=taskSnapshot.getDownloadUrl();//here i cant use getdownloadurl() function
      DatabaseReference new_prod=db.push();
      new_prod.child("product name").setValue(prod_name);
      new_prod.child("product price").setValue(prod_price);
      new_prod.child("available stock").setValue(prod_quan);
      new_prod.child("product image").setValue(downloaduri);
      pd.dismiss();//fragments code


      I was unable to use getdownloadurl .I have already stored image in the firebase storage.Is it the fragment that is restricting the use of getdownloadurl? My motive is to make a query to store in firebase.please help me.







      android firebase firebase-realtime-database firebase-storage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 28 '18 at 8:46







      saikumar kolisetty

















      asked Jun 27 '18 at 6:58









      saikumar kolisettysaikumar kolisetty

      196




      196
























          3 Answers
          3






          active

          oldest

          votes


















          2














          The taskSnapshot.getDownloadUrl() method was removed in recent versions of the Firebase Storage SDK. You will need to instead get the download URL from the StorageReference now.



          From the documentation on downloading a file:




           storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
          // Got the download URL for 'users/me/profile.png' in uri
          System.out.println(uri.toString());
          }
          }).addOnFailureListener(new OnFailureListener() {
          @Override
          public void onFailure(@NonNull Exception exception) {
          // Handle any errors
          }
          });



          Alternatively that first line could be this in your case:



          taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {


          Also see:




          • Firebase Storage getDownloadUrl() method can't be resolved

          • Error: cannot find symbol method getDownloadUrl() of type com.google.firebase.storage.UploadTask.TaskSnapshot

          • The example in the Firebase documentation on uploading a file and getting its download URL






          share|improve this answer

































            1














            This worked for me after hours of research and differents ways :



            filepath.putFile(resultUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

            //here
            Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl();
            while (!urlTask.isSuccessful());
            Uri downloadUrl = urlTask.getResult();

            final String sdownload_url = String.valueOf(downloadUrl);





            share|improve this answer


























            • It works for me

              – tushar
              Oct 27 '18 at 11:10



















            0














            storageReference.child("YOUR_CHILD")
            .putFile("FILE")
            .addOnSuccessListener(new OnSuccessListener() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
            taskSnapshot
            .getStorage()
            .getDownloadUrl()
            .addOnSuccessListener(new OnSuccessListener() {
            @Override
            public void onSuccess(Uri uri) {
            //Put your result here
            }
            });

            }





            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51056397%2fhow-to-use-getdownloadurl-in-recent-versions%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              The taskSnapshot.getDownloadUrl() method was removed in recent versions of the Firebase Storage SDK. You will need to instead get the download URL from the StorageReference now.



              From the documentation on downloading a file:




               storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
              @Override
              public void onSuccess(Uri uri) {
              // Got the download URL for 'users/me/profile.png' in uri
              System.out.println(uri.toString());
              }
              }).addOnFailureListener(new OnFailureListener() {
              @Override
              public void onFailure(@NonNull Exception exception) {
              // Handle any errors
              }
              });



              Alternatively that first line could be this in your case:



              taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {


              Also see:




              • Firebase Storage getDownloadUrl() method can't be resolved

              • Error: cannot find symbol method getDownloadUrl() of type com.google.firebase.storage.UploadTask.TaskSnapshot

              • The example in the Firebase documentation on uploading a file and getting its download URL






              share|improve this answer






























                2














                The taskSnapshot.getDownloadUrl() method was removed in recent versions of the Firebase Storage SDK. You will need to instead get the download URL from the StorageReference now.



                From the documentation on downloading a file:




                 storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                @Override
                public void onSuccess(Uri uri) {
                // Got the download URL for 'users/me/profile.png' in uri
                System.out.println(uri.toString());
                }
                }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                // Handle any errors
                }
                });



                Alternatively that first line could be this in your case:



                taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {


                Also see:




                • Firebase Storage getDownloadUrl() method can't be resolved

                • Error: cannot find symbol method getDownloadUrl() of type com.google.firebase.storage.UploadTask.TaskSnapshot

                • The example in the Firebase documentation on uploading a file and getting its download URL






                share|improve this answer




























                  2












                  2








                  2







                  The taskSnapshot.getDownloadUrl() method was removed in recent versions of the Firebase Storage SDK. You will need to instead get the download URL from the StorageReference now.



                  From the documentation on downloading a file:




                   storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                  @Override
                  public void onSuccess(Uri uri) {
                  // Got the download URL for 'users/me/profile.png' in uri
                  System.out.println(uri.toString());
                  }
                  }).addOnFailureListener(new OnFailureListener() {
                  @Override
                  public void onFailure(@NonNull Exception exception) {
                  // Handle any errors
                  }
                  });



                  Alternatively that first line could be this in your case:



                  taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {


                  Also see:




                  • Firebase Storage getDownloadUrl() method can't be resolved

                  • Error: cannot find symbol method getDownloadUrl() of type com.google.firebase.storage.UploadTask.TaskSnapshot

                  • The example in the Firebase documentation on uploading a file and getting its download URL






                  share|improve this answer















                  The taskSnapshot.getDownloadUrl() method was removed in recent versions of the Firebase Storage SDK. You will need to instead get the download URL from the StorageReference now.



                  From the documentation on downloading a file:




                   storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                  @Override
                  public void onSuccess(Uri uri) {
                  // Got the download URL for 'users/me/profile.png' in uri
                  System.out.println(uri.toString());
                  }
                  }).addOnFailureListener(new OnFailureListener() {
                  @Override
                  public void onFailure(@NonNull Exception exception) {
                  // Handle any errors
                  }
                  });



                  Alternatively that first line could be this in your case:



                  taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {


                  Also see:




                  • Firebase Storage getDownloadUrl() method can't be resolved

                  • Error: cannot find symbol method getDownloadUrl() of type com.google.firebase.storage.UploadTask.TaskSnapshot

                  • The example in the Firebase documentation on uploading a file and getting its download URL







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 15 '18 at 14:08

























                  answered Jun 27 '18 at 13:56









                  Frank van PuffelenFrank van Puffelen

                  232k29380406




                  232k29380406

























                      1














                      This worked for me after hours of research and differents ways :



                      filepath.putFile(resultUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

                      //here
                      Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl();
                      while (!urlTask.isSuccessful());
                      Uri downloadUrl = urlTask.getResult();

                      final String sdownload_url = String.valueOf(downloadUrl);





                      share|improve this answer


























                      • It works for me

                        – tushar
                        Oct 27 '18 at 11:10
















                      1














                      This worked for me after hours of research and differents ways :



                      filepath.putFile(resultUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

                      //here
                      Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl();
                      while (!urlTask.isSuccessful());
                      Uri downloadUrl = urlTask.getResult();

                      final String sdownload_url = String.valueOf(downloadUrl);





                      share|improve this answer


























                      • It works for me

                        – tushar
                        Oct 27 '18 at 11:10














                      1












                      1








                      1







                      This worked for me after hours of research and differents ways :



                      filepath.putFile(resultUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

                      //here
                      Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl();
                      while (!urlTask.isSuccessful());
                      Uri downloadUrl = urlTask.getResult();

                      final String sdownload_url = String.valueOf(downloadUrl);





                      share|improve this answer















                      This worked for me after hours of research and differents ways :



                      filepath.putFile(resultUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

                      //here
                      Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl();
                      while (!urlTask.isSuccessful());
                      Uri downloadUrl = urlTask.getResult();

                      final String sdownload_url = String.valueOf(downloadUrl);






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jul 28 '18 at 5:52









                      Firanolfind

                      873824




                      873824










                      answered Jul 28 '18 at 0:05









                      Yous SelfYous Self

                      114




                      114













                      • It works for me

                        – tushar
                        Oct 27 '18 at 11:10



















                      • It works for me

                        – tushar
                        Oct 27 '18 at 11:10

















                      It works for me

                      – tushar
                      Oct 27 '18 at 11:10





                      It works for me

                      – tushar
                      Oct 27 '18 at 11:10











                      0














                      storageReference.child("YOUR_CHILD")
                      .putFile("FILE")
                      .addOnSuccessListener(new OnSuccessListener() {
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                      taskSnapshot
                      .getStorage()
                      .getDownloadUrl()
                      .addOnSuccessListener(new OnSuccessListener() {
                      @Override
                      public void onSuccess(Uri uri) {
                      //Put your result here
                      }
                      });

                      }





                      share|improve this answer




























                        0














                        storageReference.child("YOUR_CHILD")
                        .putFile("FILE")
                        .addOnSuccessListener(new OnSuccessListener() {
                        @Override
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                        taskSnapshot
                        .getStorage()
                        .getDownloadUrl()
                        .addOnSuccessListener(new OnSuccessListener() {
                        @Override
                        public void onSuccess(Uri uri) {
                        //Put your result here
                        }
                        });

                        }





                        share|improve this answer


























                          0












                          0








                          0







                          storageReference.child("YOUR_CHILD")
                          .putFile("FILE")
                          .addOnSuccessListener(new OnSuccessListener() {
                          @Override
                          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                          taskSnapshot
                          .getStorage()
                          .getDownloadUrl()
                          .addOnSuccessListener(new OnSuccessListener() {
                          @Override
                          public void onSuccess(Uri uri) {
                          //Put your result here
                          }
                          });

                          }





                          share|improve this answer













                          storageReference.child("YOUR_CHILD")
                          .putFile("FILE")
                          .addOnSuccessListener(new OnSuccessListener() {
                          @Override
                          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                          taskSnapshot
                          .getStorage()
                          .getDownloadUrl()
                          .addOnSuccessListener(new OnSuccessListener() {
                          @Override
                          public void onSuccess(Uri uri) {
                          //Put your result here
                          }
                          });

                          }






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 24 '18 at 2:14









                          JPDroidJPDroid

                          161




                          161






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51056397%2fhow-to-use-getdownloadurl-in-recent-versions%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Bressuire

                              Vorschmack

                              Quarantine