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?










share|improve this question


























    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?










    share|improve this question
























      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 19:22









      murkr

      689




      689
























          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.






          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',
            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%2f53196376%2fandroid-upload-of-pictures-from-facebook-to-fireabse-returns-404%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
            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.






            share|improve this answer

























              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.






              share|improve this answer























                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.






                share|improve this answer












                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 8 at 14:39









                murkr

                689




                689






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    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





















































                    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







                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()