我有一个应用程序,我将图像上传到Amazon S3服务。 我已经实施了#34;更新"流(再次删除并重新添加新图像)。
有没有办法更新图像数据,而不是每次调用删除和重新添加功能,并更新新的URL?
我正在使用AWS iOS Swift SDK
//=> Delete old profile image
if let originalImageUrl = SessionManager.shared.curAccount?.pictureURL {
let str = originalImageUrl.components(separatedBy: "/")
let s3 = AWSS3.default()
let deleteRequest = AWSS3DeleteObjectRequest()
deleteRequest?.bucket = Constants.AWS_S3.S3BucketName
deleteRequest?.key = str.last
s3.deleteObject(deleteRequest!, completionHandler: { (s3Output, error) in
if error != nil {
self?.viewModel.profileOriginalImgURL.value = originalImageUrl
}
})
}
和上传,类似的东西:
if let uploadRequest = AWSS3TransferManagerUploadRequest() {
uploadRequest.body = urlProfileImageDir
uploadRequest.key = ProcessInfo.processInfo.globallyUniqueString + "." + ext
uploadRequest.bucket = Constants.AWS_S3.S3BucketName + "/" + Constants.AWS_S3.FolderProfileImages
uploadRequest.contentType = "image/" + ext
if let transferManager = AWSS3TransferManager.default() {
transferManager.upload(uploadRequest).continue({ (task) -> Any? in
if let error = task.error {
.....