使用iOS Swift将带有额外参数的文件上载到AWS S3

时间:2016-11-28 05:06:55

标签: ios swift amazon-web-services amazon-s3

就像常规的HTTP POST请求一样。我们可以添加无限参数作为表单数据。使用iOS AWS S3 SDK上传时怎么样?

我的iOS功能

let uploadRequest            = AWSS3TransferManagerUploadRequest();
uploadRequest?.body          = NSURL(string: "file://\(path)") as URL!;
uploadRequest?.key           = "file_name";
uploadRequest?.bucket        = aws_s3_bucket_path;
uploadRequest?.contentType   = "image/" + file_extension;

有什么办法可以添加更多参数发送到我的Lambda函数吗?

1 个答案:

答案 0 :(得分:1)

您可以add extra parametersmetaData提出请求。

let uploadRequest            = AWSS3TransferManagerUploadRequest();
uploadRequest?.body          = NSURL(string: "file://\(path)") as URL!;
uploadRequest?.key           = "file_name";
uploadRequest?.bucket        = aws_s3_bucket_path;
uploadRequest?.contentType   = "image/" + file_extension;
uploadRequest?.metadata      = ["PhotoTitle" : " testName", "PhotoCaption" : "TestCaption", "UserName" : "TestName", "UserAge" : "TestAge"]

感谢:)