android: upload of pictures from facebook to fireabse returns 404
up vote
0
down vote
favorite
So, I code an android app, that takes pictures from facebook and stores them in a firebase db.
I use the graph-api to get the urls of the pictures, which works fine, since I can put the urls in a browser and the pictures appear.
Now I want to use an UploadTask to upload these pictures to firebase, and I get:
E/StorageException: StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
11-07 19:58:00.894 8612-9182/com.finder E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@16.0.4:455)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@16.0.4:435)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@16.0.4:426)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:280)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:294)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:65)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:57)
at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@16.0.4:71)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Here is my upload method:
static class UploadPicAsyncWrapperTask extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... strings) {
String picsFolder = strings[0];
String id = strings[1];
final String url = strings[2];
final String profilepicNodeName = strings[3];
final String picsNodeName = strings[4];
final StorageReference filePathRoot = FirebaseStorage.getInstance().getReference().child(picsFolder).child(FirebaseAuth.getInstance().getCurrentUser().getUid());
final StorageReference filePath;
filePath = filePathRoot.child(id);
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// File already exists
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
final UploadTask uploadTask;
try (InputStream is = new URL(Uri.encode(url)).openStream()) {
uploadTask = filePath.putStream(is); //Uri.fromFile(new File(url)); //Uri.parse(url) new ByteArrayInputStream()
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
if (profilePicName == null) {
mUserDatabase.child(profilepicNodeName).setValue(uri.toString());
profilePicName = uri.toString();
} else {
mUserDatabase.child(picsNodeName).child(Helper.imageUrlToFirebasePath(uri.toString())).setValue(uri.toString());
}
--picsRemaining;
}
});
}
});
} catch (MalformedURLException e) {
// TODO or not todo whatever
} catch (IOException e) {
// TODO or not todo whatever
}
}
});
return null;
}
}
And this is how the asyncTask is called:
new UploadPicAsyncWrapperTask().execute(getString(R.string.firebase_storage_pics_folder), id, url, getString(R.string.firebase_database_profilepic_node_name), getString(R.string.firebase_database_pics_node_name));
Anybody any idea why firebase can't catch the pictures?
android facebook firebase facebook-graph-api firebase-storage
add a comment |
up vote
0
down vote
favorite
So, I code an android app, that takes pictures from facebook and stores them in a firebase db.
I use the graph-api to get the urls of the pictures, which works fine, since I can put the urls in a browser and the pictures appear.
Now I want to use an UploadTask to upload these pictures to firebase, and I get:
E/StorageException: StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
11-07 19:58:00.894 8612-9182/com.finder E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@16.0.4:455)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@16.0.4:435)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@16.0.4:426)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:280)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:294)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:65)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:57)
at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@16.0.4:71)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Here is my upload method:
static class UploadPicAsyncWrapperTask extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... strings) {
String picsFolder = strings[0];
String id = strings[1];
final String url = strings[2];
final String profilepicNodeName = strings[3];
final String picsNodeName = strings[4];
final StorageReference filePathRoot = FirebaseStorage.getInstance().getReference().child(picsFolder).child(FirebaseAuth.getInstance().getCurrentUser().getUid());
final StorageReference filePath;
filePath = filePathRoot.child(id);
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// File already exists
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
final UploadTask uploadTask;
try (InputStream is = new URL(Uri.encode(url)).openStream()) {
uploadTask = filePath.putStream(is); //Uri.fromFile(new File(url)); //Uri.parse(url) new ByteArrayInputStream()
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
if (profilePicName == null) {
mUserDatabase.child(profilepicNodeName).setValue(uri.toString());
profilePicName = uri.toString();
} else {
mUserDatabase.child(picsNodeName).child(Helper.imageUrlToFirebasePath(uri.toString())).setValue(uri.toString());
}
--picsRemaining;
}
});
}
});
} catch (MalformedURLException e) {
// TODO or not todo whatever
} catch (IOException e) {
// TODO or not todo whatever
}
}
});
return null;
}
}
And this is how the asyncTask is called:
new UploadPicAsyncWrapperTask().execute(getString(R.string.firebase_storage_pics_folder), id, url, getString(R.string.firebase_database_profilepic_node_name), getString(R.string.firebase_database_pics_node_name));
Anybody any idea why firebase can't catch the pictures?
android facebook firebase facebook-graph-api firebase-storage
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So, I code an android app, that takes pictures from facebook and stores them in a firebase db.
I use the graph-api to get the urls of the pictures, which works fine, since I can put the urls in a browser and the pictures appear.
Now I want to use an UploadTask to upload these pictures to firebase, and I get:
E/StorageException: StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
11-07 19:58:00.894 8612-9182/com.finder E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@16.0.4:455)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@16.0.4:435)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@16.0.4:426)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:280)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:294)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:65)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:57)
at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@16.0.4:71)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Here is my upload method:
static class UploadPicAsyncWrapperTask extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... strings) {
String picsFolder = strings[0];
String id = strings[1];
final String url = strings[2];
final String profilepicNodeName = strings[3];
final String picsNodeName = strings[4];
final StorageReference filePathRoot = FirebaseStorage.getInstance().getReference().child(picsFolder).child(FirebaseAuth.getInstance().getCurrentUser().getUid());
final StorageReference filePath;
filePath = filePathRoot.child(id);
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// File already exists
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
final UploadTask uploadTask;
try (InputStream is = new URL(Uri.encode(url)).openStream()) {
uploadTask = filePath.putStream(is); //Uri.fromFile(new File(url)); //Uri.parse(url) new ByteArrayInputStream()
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
if (profilePicName == null) {
mUserDatabase.child(profilepicNodeName).setValue(uri.toString());
profilePicName = uri.toString();
} else {
mUserDatabase.child(picsNodeName).child(Helper.imageUrlToFirebasePath(uri.toString())).setValue(uri.toString());
}
--picsRemaining;
}
});
}
});
} catch (MalformedURLException e) {
// TODO or not todo whatever
} catch (IOException e) {
// TODO or not todo whatever
}
}
});
return null;
}
}
And this is how the asyncTask is called:
new UploadPicAsyncWrapperTask().execute(getString(R.string.firebase_storage_pics_folder), id, url, getString(R.string.firebase_database_profilepic_node_name), getString(R.string.firebase_database_pics_node_name));
Anybody any idea why firebase can't catch the pictures?
android facebook firebase facebook-graph-api firebase-storage
So, I code an android app, that takes pictures from facebook and stores them in a firebase db.
I use the graph-api to get the urls of the pictures, which works fine, since I can put the urls in a browser and the pictures appear.
Now I want to use an UploadTask to upload these pictures to firebase, and I get:
E/StorageException: StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
11-07 19:58:00.894 8612-9182/com.finder E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object" }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@16.0.4:455)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@16.0.4:435)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@16.0.4:426)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:280)
at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@16.0.4:294)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:65)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:57)
at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@16.0.4:71)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Here is my upload method:
static class UploadPicAsyncWrapperTask extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... strings) {
String picsFolder = strings[0];
String id = strings[1];
final String url = strings[2];
final String profilepicNodeName = strings[3];
final String picsNodeName = strings[4];
final StorageReference filePathRoot = FirebaseStorage.getInstance().getReference().child(picsFolder).child(FirebaseAuth.getInstance().getCurrentUser().getUid());
final StorageReference filePath;
filePath = filePathRoot.child(id);
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// File already exists
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
final UploadTask uploadTask;
try (InputStream is = new URL(Uri.encode(url)).openStream()) {
uploadTask = filePath.putStream(is); //Uri.fromFile(new File(url)); //Uri.parse(url) new ByteArrayInputStream()
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
if (profilePicName == null) {
mUserDatabase.child(profilepicNodeName).setValue(uri.toString());
profilePicName = uri.toString();
} else {
mUserDatabase.child(picsNodeName).child(Helper.imageUrlToFirebasePath(uri.toString())).setValue(uri.toString());
}
--picsRemaining;
}
});
}
});
} catch (MalformedURLException e) {
// TODO or not todo whatever
} catch (IOException e) {
// TODO or not todo whatever
}
}
});
return null;
}
}
And this is how the asyncTask is called:
new UploadPicAsyncWrapperTask().execute(getString(R.string.firebase_storage_pics_folder), id, url, getString(R.string.firebase_database_profilepic_node_name), getString(R.string.firebase_database_pics_node_name));
Anybody any idea why firebase can't catch the pictures?
android facebook firebase facebook-graph-api firebase-storage
android facebook firebase facebook-graph-api firebase-storage
asked Nov 7 at 19:22
murkr
689
689
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
So, there is nothing wrong with my code above. Since I can't ask Firebase if a picture was already uploaded to the database, I ask firebase to give me the downloadUrl of that picture and in onFailureListener, I upload the picture.
What I didn't know is, that onFailureListener implicit logs the error message above.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
So, there is nothing wrong with my code above. Since I can't ask Firebase if a picture was already uploaded to the database, I ask firebase to give me the downloadUrl of that picture and in onFailureListener, I upload the picture.
What I didn't know is, that onFailureListener implicit logs the error message above.
add a comment |
up vote
0
down vote
So, there is nothing wrong with my code above. Since I can't ask Firebase if a picture was already uploaded to the database, I ask firebase to give me the downloadUrl of that picture and in onFailureListener, I upload the picture.
What I didn't know is, that onFailureListener implicit logs the error message above.
add a comment |
up vote
0
down vote
up vote
0
down vote
So, there is nothing wrong with my code above. Since I can't ask Firebase if a picture was already uploaded to the database, I ask firebase to give me the downloadUrl of that picture and in onFailureListener, I upload the picture.
What I didn't know is, that onFailureListener implicit logs the error message above.
So, there is nothing wrong with my code above. Since I can't ask Firebase if a picture was already uploaded to the database, I ask firebase to give me the downloadUrl of that picture and in onFailureListener, I upload the picture.
What I didn't know is, that onFailureListener implicit logs the error message above.
answered Nov 8 at 14:39
murkr
689
689
add a comment |
add a 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%2f53196376%2fandroid-upload-of-pictures-from-facebook-to-fireabse-returns-404%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