Я пытаюсь загрузить файлы / изображения / видео в AWS s3 корзину из android. Некоторые видео успешно загружены, но иногда, когда я загружаю видео, оно не загружается и выдает следующую ошибку:
com.amazonaws.AmazonClientException: Unable to verify integrity of data upload. Client
calculated content hash didn't match hash calculated by Amazon S3. You may need to delete
the data stored in Amazon S3.
2020-01-16 16:58:15.065 30740-30740/com.sirona.android W/System.err: at
com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1985)
2020-01-16 16:58:15.065 30740-30740/com.sirona.android W/System.err: at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.uploadSinglePartAndWaitForCompletion(UploadTask.java:277)
2020-01-16 16:58:15.065 30740-30740/com.sirona.android W/System.err: at
com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:115)
2020-01-16 16:58:15.065 30740-30740/com.sirona.android W/System.err: at
com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:60)
2020-01-16 16:58:15.065 30740-30740/com.sirona.android W/System.err: at
java.util.concurrent.FutureTask.run(FutureTask.java:266)
2020-01-16 16:58:15.066 30740-30740/com.sirona.android W/System.err: at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2020-01-16 16:58:15.066 30740-30740/com.sirona.android W/System.err: at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2020-01-16 16:58:15.066 30740-30740/com.sirona.android W/System.err: at
java.lang.Thread.run(Thread.java:764)
Вот мой код
private fun getS3Client(
accessKey: String,
secretKey: String,
sessionToken: String
): AmazonS3Client? {
var sS3Client: AmazonS3Client? = null
try {
val region: Region = Region.getRegion("us-west-2")
val credentials =
BasicSessionCredentials(accessKey, secretKey, sessionToken)
val clientConfiguration = ClientConfiguration()
.withMaxErrorRetry(3) // 3 retries
.withConnectionTimeout(120000) // 120,000 ms
.withSocketTimeout(120000) // 120,000 ms
sS3Client = AmazonS3Client(credentials, region, clientConfiguration)
} catch (e: JSONException) {
e.printStackTrace()
}
return sS3Client
}
val observer: TransferObserver =
transferUtility.upload(bucket_name, file.name, file,objectMetadata)
Заранее спасибо !!