我有一个捕获图像/图像的应用程序,获取文档上载策略的请求被激活,并开始上传图像/图像。当用户在前台时,图像/图像上传,但是当用户在后台时,图像/图像不会上传或无法上传。所以我想在应用程序处于后台时(背景模式)上传图像/图像。
背景(背景模式)上传图像/图像的正确路径是什么?
该应用程序是用Swift 2.3编写的
任何帮助,将不胜感激
谢谢
使用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 }
别忘了在你的app delegate中添加以下代码
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
/*
Store the completion handler.
*/
AWSS3TransferUtility.interceptApplication(application, handleEventsForBackgroundURLSession: identifier, completionHandler: completionHandler)
}