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.
java android firebase firebase-storage
add a comment |
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.
java android firebase firebase-storage
add a comment |
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.
java android firebase firebase-storage
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
java android firebase firebase-storage
edited Nov 14 at 12:51
Alex Mamo
36.4k62355
36.4k62355
asked Nov 14 at 12:09
ajay dhadhal
1019
1019
add a comment |
add a comment |
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.
@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 usingaddOnSuccessListener
you cannot overrideonSuccess()
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
|
show 1 more comment
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.
@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 usingaddOnSuccessListener
you cannot overrideonSuccess()
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
|
show 1 more comment
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.
@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 usingaddOnSuccessListener
you cannot overrideonSuccess()
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
|
show 1 more comment
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.
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.
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 usingaddOnSuccessListener
you cannot overrideonSuccess()
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
|
show 1 more comment
@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 usingaddOnSuccessListener
you cannot overrideonSuccess()
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
|
show 1 more comment
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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