我已经查看了有关此问题的几个问题和答案,但是仍然无法上传到S3存储桶。我已经在应用程序标记中的清单中声明了该服务。
每个日志语句都返回正确的信息,但是状态始终为WAITING,并且不会触发任何传输侦听器。我没有收到任何错误,并且S3存储桶仍然为空。
我究竟做错了什么?
public void uploadStoredItems() {
TransferUtility transferUtility = TransferUtility.builder()
.context(AWSProvider.getInstance().getContext())
.awsConfiguration(AWSProvider.getInstance().getConfiguration())
.s3Client(new AmazonS3Client(AWSProvider.getInstance().getIdentityManager().getCredentialsProvider()))
.build();
try {
for (File csvFile : csvFiles) {
String filename = csvFile.getName(); //.substring(csvFile.getName().lastIndexOf('/') + 1);
Log.d(TAG, "This is the filename for upload: " + filename);
// FileReader reads text files in the default encoding.
String line = null;
FileReader fileReader = new FileReader(csvFile);
// Always wrap FileReader in BufferedReader.
BufferedReader bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) {
Log.d(TAG, "Here are the lines: " + line);
}
// Always close files.
bufferedReader.close();
TransferObserver uploadObserver = transferUtility.upload(filename, csvFile);
// Gets id of the transfer.
Log.d(TAG, "This is the bucket: " + uploadObserver.getBucket());
Log.d(TAG, "This is the state: " + uploadObserver.getState());
Log.d(TAG, "This is the id: " + uploadObserver.getId());
LEATH
相关分类