相关疑难解决方法(0)

确定3G与边缘

我知道可达性示例允许检测网络是否可以通过Wifi或Cell访问,但有没有办法确定单元连接是通过3G还是EDGE?

objective-c ios

7
推荐指数
5
解决办法
9530
查看次数

我正在将数据从我的Swift应用程序上传到Amazon S3,它就像其他任何东西一样耗尽电池.如何避免这种情况?

在我的'Swift'应用程序中,我有一个将照片上传到我的Amazon S3存储桶的功能.当用户连接到WiFiLTE没有问题,但是当连接速度稍慢(例如3G)时,上传需要花费很多时间(最多一分钟),而iphone可能会损失15-20%的电池!我将照片调整到大约200-300kb,这应该不是问题.我用它的代码是:

func awsS3PhotoUploader(_ ext: String, pathToFile: String, contentType: String, automaticUpload: Bool){

        let credentialsProvider = AWSCognitoCredentialsProvider(regionType:CognitoRegionType,
                                                                identityPoolId:CognitoIdentityPoolId)
        let configuration = AWSServiceConfiguration(region:CognitoRegionType, credentialsProvider:credentialsProvider)
        AWSServiceManager.default().defaultServiceConfiguration = configuration

        let uploadRequest = AWSS3TransferManagerUploadRequest()
        uploadRequest?.body = URL(string: "file://"+pathToFile)
        uploadRequest?.key = ProcessInfo.processInfo.globallyUniqueString + "." + ext
        uploadRequest?.bucket = S3BucketName
        uploadRequest?.contentType = contentType + ext

        uploadRequest?.uploadProgress = { (bytesSent, totalBytesSent, totalBytesExpectedToSend) -> Void in
            DispatchQueue.main.async(execute: { () -> Void in
                if totalBytesExpectedToSend > 1 {
                    print(totalBytesSent)
                    print(totalBytesExpectedToSend)
                }
            }) …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services ios swift

7
推荐指数
1
解决办法
409
查看次数

标签 统计

ios ×2

amazon-s3 ×1

amazon-web-services ×1

objective-c ×1

swift ×1