0
私は、ユーザーが写真を撮ったりアップロードしたり、別のユーザーがImageView
でダウンロードして閲覧できるアプリを作っています。私はアプリのすべてのRAMを取ることを防ぐために、私は全体の画像をストレージに取得します。Firebaseからダウンロードした画像のパスを取得しますか?
ここでは標準的な式で動作しています。 https://firebase.google.com/docs/storage/android/download-files
問題は、イメージがダウンロードされているパスを取得する方法がわかりません。私はAVDのモニターでそれを見つけることができません、そして、私はダウンロードされた各写真のURLが必要です、それはカスタムですので。私は新しい場所を作ってそこに置いているが、それはうまくいかないし、道を得ることもできないようなものを試している。
public void getImageFromPath() throws IOException {
StorageReference islandRef = storageRef.child("userimages/[email protected]/[email protected]");
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File directory = new File(Environment.getDataDirectory()
+ "/Test/");
if (!directory.exists()) {
directory.mkdir();
}
final File localFile = File.createTempFile(imageFileName, ".jpg", directory);
try {
islandRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getApplicationContext(), "Downloaded", Toast.LENGTH_SHORT).show();
Log.d(TAG, "Downloaded til path");
String mCurrentPhotoPath = "file:" + localFile.getAbsolutePath();
System.out.println(mCurrentPhotoPath);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.d(TAG, "Downloaded IKKE til path");
}
});
throw new IOException("Works not");
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
}
感謝を!私は "オープンに失敗しました:ENOENT(そのようなファイルやディレクトリはありません)"という例外が出ているようです。 :(これは、これらの行のur文字列パスの直前にあります;最終ファイルlocalFile = File.createTempFile(imageFileName、 ".jpg"、ディレクトリ); 文字列パス= localFile.getAbsolutePath(); System.out.printlnテスト "+パス); – NicklasN