Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从firebase存储下载图像失败:android_Android_Firebase_Firebase Storage - Fatal编程技术网

从firebase存储下载图像失败:android

从firebase存储下载图像失败:android,android,firebase,firebase-storage,Android,Firebase,Firebase Storage,下载图像并将其存储在SD卡上不起作用。我不知道我错在哪里 此代码用于将图像上载到Firebase存储 // Get a reference to store file at photos/<FILENAME> StorageReference photoRef = mPhotosStorageReference.child(selectedImageUri.getLastPathSegment()); //Upload file to Firebase Storage photoR

下载图像并将其存储在SD卡上不起作用。我不知道我错在哪里

此代码用于将图像上载到Firebase存储

// Get a reference to store file at photos/<FILENAME>
StorageReference photoRef = mPhotosStorageReference.child(selectedImageUri.getLastPathSegment());

//Upload file to Firebase Storage
photoRef.putFile(selectedImageUri).addOnSuccessListener(this, new OnSuccessListener < UploadTask.TaskSnapshot > () {
  @Override
  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
    Log.d("TAG", "in Success method of Uploading file");
    // When the image has successfully uploaded, we get its download URL
    @SuppressWarnings("VisibleForTests")
    Uri downloadUrl = taskSnapshot.getDownloadUrl();
    // Set the download URL to the message box, so that the user can send it to the database
    Message message = new Message(null, userName, downloadUrl.toString());
    messagesDatabaseReference.push().setValue(message);

    mProgressBar.setVisibility(View.GONE);
    Toast.makeText(MainActivity.this, "Upload Successful", Toast.LENGTH_SHORT).show();
  }
});
在这里,我使用相同的
photoRef
下载用户上传的特定图像。这是正确的做法吗

photoRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener < FileDownloadTask.TaskSnapshot > () {
      @Override
      public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
        // Local temp file has been created
        Log.d("TAG", "Entered onSuccess in Download File*");
        Toast.makeText(MainActivity.this, "Download Success", Toast.LENGTH_SHORT).show();
      }
    }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception exception) {
        // Handle any errors
        Log.d("TAG", "Entered onFailure in Download File*");
        Toast.makeText(MainActivity.this, "Download Failed", Toast.LENGTH_SHORT).show();
      }
    });
这是我使用exception.getMessage()时得到的异常

这是日志猫的详细信息。它显示了从gallery中拾取照片并将其上载到Firebase存储的过程:

05-03 11:25:11.600 8577-8577/com.pc.wecare D/TAG: In Main Activity Pause Method
05-03 11:25:20.277 8577-8577/com.pc.wecare D/TAG: Entered OnActivity photo picker method
05-03 11:25:20.277 8577-8577/com.pc.wecare D/TAG: onActivityResult, requestCode: 2, resultCode: -1
05-03 11:25:20.278 8577-8577/com.pc.wecare D/TAG: onActivityResult, RC_PHOTO_PICKER: 2, RESULT_OK: -1
05-03 11:25:20.310 8577-8577/com.pc.wecare D/TAG: local file: /storage/emulated/0/Android/data/com.pc.wecare/files/images306346474jpg
05-03 11:25:20.310 8577-8577/com.pc.wecare D/TAG: Photoref: gs://wecare-8a15d.appspot.com/photos/image:27301
05-03 11:25:20.313 8577-8577/com.pc.wecare D/TAG: In Main Activity Resume Method
05-03 12:58:14.730 31570-31570/com.pc.wecare D/TAG: Entered onFailure in Download File*
05-03 12:58:17.234 31570-31570/com.pc.wecare D/TAG: in Success method of Uploading file
  • 请在舱单中检查您的许可

  • createTempFile(文件名,null,context.getCacheDir())

  • 这不是文件扩展名

    请检查您的文件路径

    /存储/仿真/0/Android/data/com.pc.wecare/files/images216155570jpg 图像211615570.jpg

  • 请在舱单中检查您的许可

  • createTempFile(文件名,null,context.getCacheDir())

  • 这不是文件扩展名

    请检查您的文件路径

    /存储/仿真/0/Android/data/com.pc.wecare/files/images216155570jpg
    图像211615570.jpg

    我可以知道当我添加您提到的第二点时会发生什么情况吗?所以你想让我编辑
    File.createTempFile(“images”,“jpg”,getExternalFilesDir(null))
    to
    File.createTempFile(文件名,null,context.getCacheDir())?对!或File File=新文件(this.getCacheDir(),文件名);createNewFile();请添加。(dot)localFile=File.createTempFile(“images”、“.jpg”、getExternalFilesDir(null));我可以知道当我添加你提到的第二点时会发生什么吗?所以你想让我编辑
    File.createTempFile(“images”,“jpg”,getExternalFilesDir(null))
    to
    File.createTempFile(文件名,null,context.getCacheDir())?对!或File File=新文件(this.getCacheDir(),文件名);createNewFile();请添加。(dot)localFile=File.createTempFile(“images”、“.jpg”、getExternalFilesDir(null));日志输出显示下载文件中输入的onSuccess。失败是什么?就是这样。这是我的航海日志上显示的。我想它没有在失败时输入
    onFailure
    @bobsnyder。日志输出表明下载成功。你没有找到你想要的文件吗?没错!它显示下载成功,但我无法在我的手机图库或SD卡目录中看到该文件@BobSnyderI看到您已经更新了发布的日志输出,现在显示下载失败。更改日志语句以输出失败原因:
    exception.getMessage()
    并发布输出。日志输出显示下载文件中输入的onSuccess。失败是什么?就是这样。这是我的航海日志上显示的。我想它没有在失败时输入
    onFailure
    @bobsnyder。日志输出表明下载成功。你没有找到你想要的文件吗?没错!它显示下载成功,但我无法在我的手机图库或SD卡目录中看到该文件@BobSnyderI看到您已经更新了发布的日志输出,现在显示下载失败。更改日志语句以输出失败原因:
    exception.getMessage()
    并发布输出。
    Photoref: gs://wecare-8a15d.appspot.com/photos/image:27410
    local file: /storage/emulated/0/Android/data/com.pc.wecare/files/images2116155570jpg
    
    Excecption message: Object does not exist at location.
    
    05-03 11:25:11.600 8577-8577/com.pc.wecare D/TAG: In Main Activity Pause Method
    05-03 11:25:20.277 8577-8577/com.pc.wecare D/TAG: Entered OnActivity photo picker method
    05-03 11:25:20.277 8577-8577/com.pc.wecare D/TAG: onActivityResult, requestCode: 2, resultCode: -1
    05-03 11:25:20.278 8577-8577/com.pc.wecare D/TAG: onActivityResult, RC_PHOTO_PICKER: 2, RESULT_OK: -1
    05-03 11:25:20.310 8577-8577/com.pc.wecare D/TAG: local file: /storage/emulated/0/Android/data/com.pc.wecare/files/images306346474jpg
    05-03 11:25:20.310 8577-8577/com.pc.wecare D/TAG: Photoref: gs://wecare-8a15d.appspot.com/photos/image:27301
    05-03 11:25:20.313 8577-8577/com.pc.wecare D/TAG: In Main Activity Resume Method
    05-03 12:58:14.730 31570-31570/com.pc.wecare D/TAG: Entered onFailure in Download File*
    05-03 12:58:17.234 31570-31570/com.pc.wecare D/TAG: in Success method of Uploading file