AWS:DeveloperAuthenticatedIdentityProvider未触发IOS Swift

AWS:DeveloperAuthenticatedIdentityProvider未触发IOS Swift,第1张

概述我正在尝试集成S3上传以上传视频文件并尝试使用Developer认证身份方法.根据 aws docs所说,一切都配置完毕. DeveloperAuthenticatedIdentityProvider类: class DeveloperAuthenticatedIdentityProvider : AWSCognitoCredentialsProviderHelper { override 我正在尝试集成S3上传以上传视频文件并尝试使用Developer认证身份方法.根据 aws docs所说,一切都配置完毕.

DeveloperAuthenticatedIDentityProvIDer类:

class DeveloperAuthenticatedIDentityProvIDer : AWSCognitoCredentialsProvIDerHelper {    overrIDe func token() -> AWSTask<Nsstring> {    //return AWSTask //with token and will set IDentityID}

然后

let devAuth = DeveloperAuthenticatedIDentityProvIDer(regionType: COGNITO_REGION,IDentityPoolID: COGNITO_POol_ID,useEnhancedFlow: true,IDentityProvIDerManager:nil)let credentialsProvIDer = AWSCognitoCredentialsProvIDer(regionType: COGNITO_REGION,IDentityProvIDer:devAuth)let configuration = AWSServiceConfiguration(region: S3_REGION,credentialsProvIDer:credentialsProvIDer)AWSServiceManager.default().defaultServiceConfiguration = configuration

配置这些东西之后尝试使用awss3transfermanager上传

let transferManager = awss3transfermanager.default()let uploadingfileURL = URL(fileURLWithPath: "your/file/path/myTestfile.txt")let uploadRequest = awss3transfermanagerUploadRequest()uploadRequest.bucket = "myBucket"uploadRequest.key = "myTestfile.txt"uploadRequest.body = uploadingfileURLtransferManager.upload(uploadRequest).continueWith(executor: AWSExecutor.mainThread(),block: { (task:AWSTask<AnyObject>) -> Any? in    if let error = task.error as? NSError {        if error.domain == awss3transfermanagerErrorDomain,let code = awss3transfermanagerErrorType(rawValue: error.code) {            switch code {            case .cancelled,.paused:                break            default:                print("Error uploading: \(uploadRequest.key) Error: \(error)")            }        } else {            print("Error uploading: \(uploadRequest.key) Error: \(error)")        }        return nil    }    let uploadOutput = task.result    print("Upload complete for: \(uploadRequest.key)")    return nil})

每当我调用上传方法时,它就显示出来

[Error Domain=com.amazonaws.AWSCognitoIDentityErrorDomain Code=8
“(null)” UserInfo={__type=NotAuthorizedException,
message=Unauthenticated access is not supported for this IDentity
pool.}]

DeveloperAuthenticatedIDentityProvIDer也没有被解雇

请帮忙.

解决方法 当您使用开发人员身份验证身份进行身份识别身份提供时,您无需使用
 awss3transfermanager.default()
您需要使用密钥将AWSServiceConfiguration注册到awss3transfermanager.

awss3transfermanager.register(with: configuration!,forKey:
“KEY”)

试试这种方式:

let devAuth = DeveloperAuthenticatedIDentityProvIDer(regionType:  COGNITO_REGION,IDentityProvIDerManager:nil)    let credentialsProvIDer = AWSCognitoCredentialsProvIDer(regionType: COGNITO_REGION,IDentityProvIDer:devAuth)    let configuration = AWSServiceConfiguration(region: S3_REGION,credentialsProvIDer:credentialsProvIDer)    awss3transfermanager.register(with: configuration!,forKey: "YOUR_KEY")//Start Uploadlet uploadRequest = awss3transfermanagerUploadRequest() //Set all propertIEs to uploadRequest    awss3transfermanager.s3TransferManager(forKey: "YOUR_KEY").upload(uploadRequest!).continueWith(executor: AWSExecutor.mainThread(),block: { (task:AWSTask<AnyObject>) -> Any? in                // Do something with the response                if task.isCancelled {                    print("Cancelled Upload")                }                else if (task.error != nil) {                    print("Upload error --> \(task.error)")                }else{                    print("Upload success!!! Be happy :)")                }                return task            })

试试吧,我认为它可能会奏效.

总结

以上是内存溢出为你收集整理的AWS:DeveloperAuthenticatedIdentityProvider未触发IOS Swift全部内容,希望文章能够帮你解决AWS:DeveloperAuthenticatedIdentityProvider未触发IOS Swift所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1067105.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存