How to get offline uploded file Download url in Firebase











up vote
0
down vote

favorite












I want to get Download Url from uploadTask.addOnProgressListener method of Firebae. How I can get Download Url using following code?



    UploadTask uploadTask = storageRef.putBytes(data);

uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>()
{
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot)
{
Log.d("aaaaasessin",""+taskSnapshot.getTask().getResult());
}
});


I used taskSnapshot.getTask().getResult() but not working. Pease Help me.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I want to get Download Url from uploadTask.addOnProgressListener method of Firebae. How I can get Download Url using following code?



        UploadTask uploadTask = storageRef.putBytes(data);

    uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>()
    {
    @Override
    public void onProgress(UploadTask.TaskSnapshot taskSnapshot)
    {
    Log.d("aaaaasessin",""+taskSnapshot.getTask().getResult());
    }
    });


    I used taskSnapshot.getTask().getResult() but not working. Pease Help me.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to get Download Url from uploadTask.addOnProgressListener method of Firebae. How I can get Download Url using following code?



          UploadTask uploadTask = storageRef.putBytes(data);

      uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>()
      {
      @Override
      public void onProgress(UploadTask.TaskSnapshot taskSnapshot)
      {
      Log.d("aaaaasessin",""+taskSnapshot.getTask().getResult());
      }
      });


      I used taskSnapshot.getTask().getResult() but not working. Pease Help me.










      share|improve this question















      I want to get Download Url from uploadTask.addOnProgressListener method of Firebae. How I can get Download Url using following code?



          UploadTask uploadTask = storageRef.putBytes(data);

      uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>()
      {
      @Override
      public void onProgress(UploadTask.TaskSnapshot taskSnapshot)
      {
      Log.d("aaaaasessin",""+taskSnapshot.getTask().getResult());
      }
      });


      I used taskSnapshot.getTask().getResult() but not working. Pease Help me.







      java android firebase firebase-storage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 at 12:51









      Alex Mamo

      36.4k62355




      36.4k62355










      asked Nov 14 at 12:09









      ajay dhadhal

      1019




      1019
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          In order to get the download url, you need to use addOnSuccessListener, like in the following lines of code:



          uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
          @Override
          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
          storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
          String url = uri.toString();

          //Do what you need to do with url
          }
          });
          }
          });


          But rememeber, neither the success listener nor the failure listener (if you intend to use it), will be called if your device cannot reach Firebase Storage backend.
          The success/failure listeners will only be called once the data is committed to, or rejected by the Firebase servers.






          share|improve this answer























          • @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
            – Alex Mamo
            Nov 14 at 14:29










          • Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
            – ajay dhadhal
            Nov 15 at 5:07












          • Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
            – Alex Mamo
            Nov 15 at 7:18










          • OK,any alternative way avilable if so please suggest me
            – ajay dhadhal
            Nov 15 at 7:25










          • No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
            – Alex Mamo
            Nov 15 at 7:28













          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',
          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%2f53299915%2fhow-to-get-offline-uploded-file-download-url-in-firebase%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          In order to get the download url, you need to use addOnSuccessListener, like in the following lines of code:



          uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
          @Override
          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
          storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
          String url = uri.toString();

          //Do what you need to do with url
          }
          });
          }
          });


          But rememeber, neither the success listener nor the failure listener (if you intend to use it), will be called if your device cannot reach Firebase Storage backend.
          The success/failure listeners will only be called once the data is committed to, or rejected by the Firebase servers.






          share|improve this answer























          • @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
            – Alex Mamo
            Nov 14 at 14:29










          • Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
            – ajay dhadhal
            Nov 15 at 5:07












          • Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
            – Alex Mamo
            Nov 15 at 7:18










          • OK,any alternative way avilable if so please suggest me
            – ajay dhadhal
            Nov 15 at 7:25










          • No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
            – Alex Mamo
            Nov 15 at 7:28

















          up vote
          1
          down vote













          In order to get the download url, you need to use addOnSuccessListener, like in the following lines of code:



          uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
          @Override
          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
          storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
          String url = uri.toString();

          //Do what you need to do with url
          }
          });
          }
          });


          But rememeber, neither the success listener nor the failure listener (if you intend to use it), will be called if your device cannot reach Firebase Storage backend.
          The success/failure listeners will only be called once the data is committed to, or rejected by the Firebase servers.






          share|improve this answer























          • @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
            – Alex Mamo
            Nov 14 at 14:29










          • Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
            – ajay dhadhal
            Nov 15 at 5:07












          • Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
            – Alex Mamo
            Nov 15 at 7:18










          • OK,any alternative way avilable if so please suggest me
            – ajay dhadhal
            Nov 15 at 7:25










          • No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
            – Alex Mamo
            Nov 15 at 7:28















          up vote
          1
          down vote










          up vote
          1
          down vote









          In order to get the download url, you need to use addOnSuccessListener, like in the following lines of code:



          uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
          @Override
          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
          storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
          String url = uri.toString();

          //Do what you need to do with url
          }
          });
          }
          });


          But rememeber, neither the success listener nor the failure listener (if you intend to use it), will be called if your device cannot reach Firebase Storage backend.
          The success/failure listeners will only be called once the data is committed to, or rejected by the Firebase servers.






          share|improve this answer














          In order to get the download url, you need to use addOnSuccessListener, like in the following lines of code:



          uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
          @Override
          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
          storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
          String url = uri.toString();

          //Do what you need to do with url
          }
          });
          }
          });


          But rememeber, neither the success listener nor the failure listener (if you intend to use it), will be called if your device cannot reach Firebase Storage backend.
          The success/failure listeners will only be called once the data is committed to, or rejected by the Firebase servers.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 14 at 14:28

























          answered Nov 14 at 12:49









          Alex Mamo

          36.4k62355




          36.4k62355












          • @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
            – Alex Mamo
            Nov 14 at 14:29










          • Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
            – ajay dhadhal
            Nov 15 at 5:07












          • Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
            – Alex Mamo
            Nov 15 at 7:18










          • OK,any alternative way avilable if so please suggest me
            – ajay dhadhal
            Nov 15 at 7:25










          • No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
            – Alex Mamo
            Nov 15 at 7:28




















          • @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
            – Alex Mamo
            Nov 14 at 14:29










          • Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
            – ajay dhadhal
            Nov 15 at 5:07












          • Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
            – Alex Mamo
            Nov 15 at 7:18










          • OK,any alternative way avilable if so please suggest me
            – ajay dhadhal
            Nov 15 at 7:25










          • No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
            – Alex Mamo
            Nov 15 at 7:28


















          @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
          – Alex Mamo
          Nov 14 at 14:29




          @FrankvanPuffelen Oh sorry, my bad. Answer updated. Thanks again!
          – Alex Mamo
          Nov 14 at 14:29












          Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
          – ajay dhadhal
          Nov 15 at 5:07






          Thanks for your answer but,I perform upload task offline so i can't use onSuccsess().I have to use only uploadTask.addOnProgressListener()
          – ajay dhadhal
          Nov 15 at 5:07














          Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
          – Alex Mamo
          Nov 15 at 7:18




          Yes, that's correct, onSuccsess() is not triggered while offile but unfortunately using addOnSuccessListener you cannot override onSuccess() method to get the download url. Which makes sense because you can only get the download url only once you get a responde from the server (onSuccess is triggered). You cannot get a download url as long as the task is not completed, right?
          – Alex Mamo
          Nov 15 at 7:18












          OK,any alternative way avilable if so please suggest me
          – ajay dhadhal
          Nov 15 at 7:25




          OK,any alternative way avilable if so please suggest me
          – ajay dhadhal
          Nov 15 at 7:25












          No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
          – Alex Mamo
          Nov 15 at 7:28






          No, there is not. You can get the download url only when the upload is successful, with other words when the server provides you the url. When you are offline and there is no direct connection between the device and to the server, there is no url that you can get. Can I help you with other informations?
          – Alex Mamo
          Nov 15 at 7:28




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299915%2fhow-to-get-offline-uploded-file-download-url-in-firebase%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

          Costa Masnaga

          Fotorealismo

          Sidney Franklin