У меня есть эта проблема в onError загрузки: Невозможно выполнить HTTP-запрос: Ошибка записи: ssl = 0x7b4a65b280: Ошибка ввода-вывода во время системного вызова, Сброс соединения по пиру
Не знаю почему, я тоже следовал инструкциям.
У меня есть <service android:name="com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true" />
в манифесте
У меня есть implementation 'com.amazonaws:aws-android-sdk-s3:2.2.+'
во внутреннем gradle
Мой код:
public void upload(String path,File file) {
path=path.replace("/storage/emulated/0/blablabla/","");
// Initialize the Amazon Cognito credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"blablabla", // Identity pool ID
Regions.EU_WEST_1 // Region
);
AmazonS3 s3 = new AmazonS3Client(credentialsProvider);
TransferUtility transferUtility = new TransferUtility(s3, getApplicationContext());
final TransferObserver observer = transferUtility.upload(
"blablabla", //this is the bucket name on S3
path, //this is the path and name
file //path to the file locally
);
observer.setTransferListener(new TransferListener() {
@Override
public void onStateChanged(int id, TransferState state) {
if (state.equals(TransferState.COMPLETED)) {
Log.d("AMAZON","si");
} else if (state.equals(TransferState.FAILED)) {
//Failed
Log.d("AMAZON","no");
}
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
}
@Override
public void onError(int id, Exception ex) {
Log.d("AMAZON",ex.getMessage());
}
});
}