从iPhone App上传文件到Amazon S3,需要遵循以下步骤:
import AWSS3
func uploadFileToS3(fileURL: URL, bucketName: String, key: String) {
let transferManager = AWSS3TransferManager.default()
let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest?.bucket = bucketName
uploadRequest?.key = key
uploadRequest?.body = fileURL
transferManager.upload(uploadRequest).continueWith { (task) -> Any? in
if let error = task.error {
print("Error uploading file: \(error.localizedDescription)")
} else {
print("File uploaded successfully")
}
return nil
}
}
通过以上步骤,可以实现从iPhone App上传文件到Amazon S3的功能。推荐的腾讯云相关产品包括对象存储(COS)和API网关,产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云