我有一个捕获图像的应用程序,触发获取文档上传策略的请求,并开始上传图像。当用户在前台时,图像会上传,但当用户在后台时,图像不会上传或上传失败。因此,我想在应用程序在后台时上传图像(后台模式)。图像后台(后台模式)上传的正确路径是什么?该应用程序采用Swift 2.3编写任何帮助都将不胜感激谢谢
vx6bjr1n1#
使用处理后台上载的AWSS3TransferUtility
import AWSS3 let transferUtility = AWSS3TransferUtility.default() //In order to customize the header information, we use the AWSS3TransferUtilityUploadExpression class let expression = AWSS3TransferUtilityUploadExpression() //We want our file to be publicly available by default expression.setValue("public-read", forRequestParameter: "x-amz-acl") //Copy the custom Meta information into the expression transferUtility.uploadFile(uploadRequest.body, bucket: uploadRequest.bucket ?? "", key: uploadRequest.key ?? "", contentType: uploadRequest.contentType ?? "", expression: expression) { (task, error) in }
import AWSS3
let transferUtility = AWSS3TransferUtility.default()
//In order to customize the header information, we use the AWSS3TransferUtilityUploadExpression class
let expression = AWSS3TransferUtilityUploadExpression()
//We want our file to be publicly available by default
expression.setValue("public-read", forRequestParameter: "x-amz-acl")
//Copy the custom Meta information into the expression
transferUtility.uploadFile(uploadRequest.body, bucket: uploadRequest.bucket ?? "", key: uploadRequest.key ?? "", contentType: uploadRequest.contentType ?? "", expression: expression) { (task, error) in }
不要忘记在应用程序委托中添加以下代码
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) { /* Store the completion handler. */ AWSS3TransferUtility.interceptApplication(application, handleEventsForBackgroundURLSession: identifier, completionHandler: completionHandler)}
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
/*
Store the completion handler.
*/
AWSS3TransferUtility.interceptApplication(application, handleEventsForBackgroundURLSession: identifier, completionHandler: completionHandler)
}
1条答案
按热度按时间vx6bjr1n1#
使用处理后台上载的AWSS3TransferUtility
不要忘记在应用程序委托中添加以下代码