我正在使用聊天应用程序,我们有两个客户端,一个是Android,另一个是网络,当我从Web App向Android发送媒体文件时,我正在将媒体文件上传到 S3-Amazon 客户端媒体文件未下载,显示错误。
Media Download interrupted : com.amazonaws.services.s3.model.AmazonS3Exception: The specified key does not exist. (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey; Request ID: XXXXXXXXX), S3 Extended Request ID:XXXXXXXXXXX
private void beginDownload(String key, String bucket, String
mediaType,final
DownloadFileFromAwsCompletionListener listener) {
// Location to download files from S3 to. You can choose any
accessible
// file.
String localFilePath = Strings.EMPTY;
try {
//if (!isThumb) {
localFilePath = MediaHelper.createMediaFile(mediaType, false, false, key);
/* } else {
localFilePath = MediaHelper.createMediaFile(mediaType, false, true);
}*/
} catch (Exception e) {
e.printStackTrace();
}
if (!StringHelper.isNullOrEmpty(localFilePath)) {
File file = new File(localFilePath);
// Initiate the download
TransferObserver observer = mTransferUtility.download(bucket, key, file);
final String finalLocalFilePath = localFilePath;
observer.setTransferListener(new TransferListener() {
@Override
public void onStateChanged(int id, TransferState state) {
//String bucketPath = UrlStrings.XmppStrings.
if (state.equals(TransferState.COMPLETED)) {
listener.onDownloadSuccess(finalLocalFilePath);
}
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
}
@Override
public void onError(int id, Exception ex) {
listener.onDatabaseError(new AwsFailure(ex));
}
});
} else {
getLogger().log(Strings.TAG, "xmpp beginDownload(): file could not be created.");
}
}
答案 0 :(得分:0)
您应该交叉检查上载的路径,该路径与从S3下载媒体文件所使用的路径相同。我认为您正在使用不同的路径来下载媒体文件,这就是为什么您遇到错误。