初始化SDK 接入方式 方式一:使用官网下载的SDK 在官网下载SDK,下载地址:IOS SDK。 下载完成之后,解压到项目根路径下,配置Podfile plaintext target 'CtyunS3Demo' do pod 'AWSS3', :path > './ossiossdk' pod 'AWSCore', :path > './ossiossdk' end 方式二:直接使用aws的SDK 直接配置Podfile plaintext target 'CtyunS3Demo' do pod 'AWSS3' end 初始化SDK 注意:直接在客户端上使用主账号存在账号泄露的风险,在客户端上必须使用sts功能生成的临时账号,此初始化流程只能用于测试。如何使用sts初始化参考STS相关接口。 引用sdk的头文件 plaintext import 通过sdk使用s3服务的时候主要需要设置3个配置参数,accessKey,secretKey和endpoint,使用以下方法进行设置,完成sdk的初始化。 plaintext (id)init { if (self [super init]) { AWSStaticCredentialsProvider credentialsProvider [[AWSStaticCredentialsProvider alloc] initWithAccessKey:@"填入你的accesskey" secretKey:@"填入你的secretkey"]; AWSEndpoint endPoint [[AWSEndpoint alloc] initWithURLString:@" AWSServiceConfiguration configuration [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 endpoint:endPoint credentialsProvider:credentialsProvider]; [AWSServiceManager defaultServiceManager].defaultServiceConfiguration configuration; self.s3 [AWSS3 defaultS3]; } return self; } 参数说明: 参数 说明 accessKey 用户账号 access key secretKey 用户账号 secret key endpoint 天翼云资源池的地址,必须指定http或https前缀