forked from aliyun/aliyun-oss-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into refactor/sample
- Loading branch information
Showing
10 changed files
with
222 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
需要引入OSS iOS SDK framework。 | ||
|
||
您可以在MacOS系统中直接使用在本工程生成framwork: | ||
您可以在MacOS系统中直接使用本工程,选择对应的scheme为AliyunOSSSDK OSX,然后生成framwork: | ||
|
||
```bash | ||
# clone工程 | ||
|
@@ -26,16 +26,16 @@ $ git clone [email protected]:aliyun/aliyun-oss-ios-sdk.git | |
$ cd aliyun-oss-ios-sdk | ||
|
||
# 执行打包脚本 | ||
$ sh ./buildFramework.sh | ||
$ sh ./buildiOSFramework.sh | ||
|
||
# 进入打包生成目录,AliyunOSSiOS.framework生成在该目录下 | ||
$ cd Products && ls | ||
``` | ||
|
||
注意:buildFramework.sh脚本生成的framework是支持i386,x86_64,armv7,arm64架构的版本,所以当您需要archive product时,需要直接使用工程文件生成只支持真机的framework版本。 | ||
|
||
在Xcode中,直接把framework拖入您对应的Target下即可,在弹出框勾选`Copy items if needed`。 | ||
|
||
**注意:buildiOSFramework.sh脚本生成的framework是支持i386,x86_64,armv7,arm64架构的版本,所以当您需要archive product时,需要直接使用工程文件生成只支持真机的framework版本。** | ||
|
||
### Pod依赖 | ||
|
||
如果工程是通过pod管理依赖,那么在Podfile中加入以下依赖即可,不需要再导入framework: | ||
|
@@ -79,8 +79,6 @@ WWDC 2016开发者大会上,苹果宣布从2017年1月1日起,苹果App Stor | |
|
||
### 对于OSSTask的一些说明 | ||
|
||
**注意: 建议OSSClient的生命周期和应用程序的生命周期保持一致(如果您不希望这样,也可以在调用API时增加[task waitUntilFinished]以确保在task完成之前OSSClient不被释放)。** | ||
|
||
所有调用api的操作,都会立即获得一个OSSTask,如: | ||
|
||
``` | ||
|
@@ -120,12 +118,48 @@ demo示例: [点击查看](https://github.com/alibaba/alicloud-ios-demo)。 | |
|
||
在移动环境下,我们推荐STS鉴权模式来初始化OSSClient。鉴权细节详见后面链接给出的官网完整文档的`访问控制`章节。 | ||
|
||
**注意: 如果您的应用只用到一个[数据中心](https://help.aliyun.com/document_detail/31837.html)下的bucket,建议保持OSSClient实例与应用程序的生命周期一致(比如在Appdelegate.m的 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions])中进行初始化,如下所示:** | ||
|
||
```objc | ||
NSString *endpoint = @"https://oss-cn-hangzhou.aliyuncs.com"; | ||
@interface AppDelegate () | ||
|
||
@property (nonatomic, strong) OSSClient *client; | ||
|
||
@end | ||
|
||
/** | ||
* 获取sts信息的url,配置在业务方自己的搭建的服务器上。详情可见https://help.aliyun.com/document_detail/31920.html | ||
*/ | ||
#define OSS_STS_URL @"oss_sts_url" | ||
|
||
|
||
/** | ||
* bucket所在的region的endpoint,详情可见https://help.aliyun.com/document_detail/31837.html | ||
*/ | ||
#define OSS_ENDPOINT @"your bucket's endpoint" | ||
|
||
@implementation AppDelegate | ||
|
||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
// Override point for customization after application launch. | ||
|
||
// 初始化OSSClient实例 | ||
[self setupOSSClient]; | ||
|
||
return YES; | ||
} | ||
|
||
id<OSSCredentialProvider> credential = [[OSSStsTokenCredentialProvider alloc] initWithAccessKeyId:@"<StsToken.AccessKeyId>" secretKeyId:@"<StsToken.SecretKeyId>" securityToken:@"<StsToken.SecurityToken>"]; | ||
- (void)setupOSSClient { | ||
|
||
client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credential]; | ||
// 初始化具有自动刷新的provider | ||
OSSAuthCredentialProvider *credentialProvider = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:OSS_STS_URL]; | ||
|
||
// client端的配置,如超时时间,开启dns解析等等 | ||
OSSClientConfiguration *cfg = [[OSSClientConfiguration alloc] init]; | ||
|
||
_client = [[OSSClient alloc] initWithEndpoint:OSS_ENDPOINT credentialProvider:credentialProvider clientConfiguration:cfg]; | ||
} | ||
|
||
``` | ||
|
Oops, something went wrong.