想设置凭据(accessKey,secretKey),端点,区域,
val transferUtility: TransferUtility =
TransferUtility.builder()
.context(getApplicationContext())
.awsConfiguration(AWSMobileClient.getInstance().configuration)
.s3Client( AmazonS3Client(AWSMobileClient.getInstance()))
.build();
在Ios Swift中,它的工作原理如下
let credentialsProvider = AWSStaticCredentialsProvider(
accessKey: AppHelper.getAWS3AccessKey(),
secretKey: AppHelper.getAWS3SecretKey()
)
let endpoint = AWSEndpoint(
urlString: “https:myurl”
)
let configuration = AWSServiceConfiguration(
region: .USWest1,
endpoint: endpoint,
credentialsProvider: credentialsProvider
)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let key = “images/\(ProcessInfo.processInfo.globallyUniqueString)/” + “\(AppHelper.currentUserIdString()).\(Date().timeIntervalSince1970).png”
transferUtility.uploadData(
imageData,
bucket: AppHelper.getAWS3Bucket(),
key: key,
contentType: “image/png”,
expression: nil) { (task, error) in
if let error = error {
self.errorDelegate?.didErrorOccur(error: error.localizedDescription, statusCode: nil)
} else {
self.update(imagePath: key, name: name, email: email, showScore: showScore)
}
}
}
我正在关注最新文档 https://aws-amplify.github.io/docs/android/storage。