0
目前,我試圖下載我在亞馬遜S3上的存儲桶中的文件。我正在使用這段代碼進行調試,因爲當我試圖從文件中讀取文件時,總是會找不到EN0ENT /文件。從Android的亞馬遜S3下載對象使文件無法讀取
String str_FilePathInDevice = "/sdcard/" + "/"
+ "RestoreFolderName" + "/" + "filname.extention";
File file = new File(str_FilePathInDevice);
String str_Path = file.getPath().replace(file.getName(), "");
File filedir = new File(str_Path);
try {
filedir.mkdirs();
file.createNewFile();
} catch (Exception ex1) {
}
System.out.println(file.toString());
System.out.println(file.canRead());
System.out.println(file.length());
TransferObserver observer2 = transferUtility.download(
"arabianbucket", /* The bucket to upload to */
"demo.txt", /* The key for the uploaded object */
file /* The file where the data to upload exists*/
);
System.out.println(file.toString());
System.out.println(file.canRead());
System.out.println(file.length());
file.canread()最終在transferutility.download鏈接後從true到false翻轉。我不確定爲什麼會這樣。有誰知道如何成功讀取亞馬遜S3中的對象?在我的清單中,我已經翻轉了權限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
謝謝!
可能想與此用戶聊天 - http://stackoverflow.com/questions/37768060/android-downloading-from-s3-aws –
你正在創建的文件的路徑是什麼?你應該使用'getExternalStorage()'來獲得你想要的文件夾 –
@ cricket_007我試過getExternalStorage,但我似乎仍然無法打開文件。 –