1
我使用getObject api從aws s3下載文件。簡單的文本文件工作正常,但在PDF下載我的文件已損壞。我正在使用FileOutputStream並將內容保存在文件中,但保存的PDF已損壞。aws s3 java sdk下載pdf被損壞
我不太確定用於此目的的正確的java api,以及讀取字節的字節數組的大小應該是多少。
我也很好奇,如果使用SDK直接有意義,或者是有開源的包裝API可用Java可用,我可以利用。
FileOutputStream fout = new FileOutputStream(new File(destFileName));
byte[] b = new byte[8192];
int bytesRead;
while (true) {
bytesRead = input.read(b);
System.out.println("bytesRead = "+bytesRead);
if (bytesRead==-1)
break;
fout.write(b);
}
fout.flush();
fout.close();
這正是問題所在,非常感謝。 – archie 2011-04-11 06:57:55