Skip to content

Commit

Permalink
添加快速开始的中文介绍文档,修改工程
Browse files Browse the repository at this point in the history
  • Loading branch information
duan007a committed Nov 29, 2018
1 parent b156824 commit 22652b7
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 26 deletions.
26 changes: 13 additions & 13 deletions AliyunOSSiOSTests/OSSTestMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
#ifndef OSSTestMacros_h
#define OSSTestMacros_h

#define OSS_ACCESSKEY_ID @"******"
#define OSS_SECRETKEY_ID @"******"
#define OSS_ACCESSKEY_ID @"AccessKeyID" // 子账号id
#define OSS_SECRETKEY_ID @"AccessKeySecret" // 子账号secret

#define OSS_BUCKET_PUBLIC @"public"
#define OSS_BUCKET_PRIVATE @"private"
#define OSS_ENDPOINT @"http://oss-cn-region.aliyuncs.com"
#define OSS_IMG_ENDPOINT @"http://img-cn-region.aliyuncs.com"
#define OSS_MULTIPART_UPLOADKEY @"multipart_key"
#define OSS_RESUMABLE_UPLOADKEY @"resumable_key"
#define OSS_CALLBACK_URL @"http://oss-demo.aliyuncs.com:23450"
#define OSS_CNAME_URL @"http://www.cnametest.com/"
#define OSS_STSTOKEN_URL @"http://*.*.*.*:*/sts/getsts"
#define OSS_IMAGE_KEY @"hasky.jpeg"
#define OSS_BUCKET_PUBLIC @"public-bucket" // bucket名称
#define OSS_BUCKET_PRIVATE @"private-bucket" // bucket名称
#define OSS_ENDPOINT @"http://oss-cn-region.aliyuncs.com" // 访问的阿里云endpoint
#define OSS_IMG_ENDPOINT @"http://img-cn-region.aliyuncs.com" // 旧版本图片服务的endpoint
#define OSS_MULTIPART_UPLOADKEY @"multipart_key" // 分片上传的object key
#define OSS_RESUMABLE_UPLOADKEY @"resumable_key" // 断点续传的object key
#define OSS_CALLBACK_URL @"http://oss-demo.aliyuncs.com:23450" // 对象上传成功时回调的业务服务器地址
#define OSS_CNAME_URL @"http://www.cnametest.com/" // cname,用于替换bucket.endpoint的访问域名
#define OSS_STSTOKEN_URL @"http://*.*.*.*:****/sts/getsts" // sts授权服务器的地址
#define OSS_IMAGE_KEY @"testImage.png" // 测试图片的名称

#define OSS_DOWNLOAD_FILE_NAME @"OSS_DOWNLOAD_FILE_NAME"
#define OSS_DOWNLOAD_FILE_NAME @"OSS_DOWNLOAD_FILE_NAME" // 用于下载的object key

#endif /* OSSTestMacros_h */
Binary file added Images/account_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/schemes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/swiftglobalconfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/testmacros.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/workspace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions OSSSwiftDemo/OSSSwiftDemo/Classes/OSSRootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class OSSRootViewController: UIViewController, URLSessionDelegate, URLSessionDat
mProvider = OSSAuthCredentialProvider(authServerUrl: OSS_STSTOKEN_URL)
mClient = OSSClient(endpoint: OSS_ENDPOINT, credentialProvider: mProvider)
serverURLTF.text = OSS_STSTOKEN_URL
bucketNameTF.text = OSS_BUCKET_PUBLIC
bucketNameTF.text = OSS_BUCKET_PRIVATE
objectKeyTF.text = nil
}

Expand Down Expand Up @@ -135,7 +135,7 @@ class OSSRootViewController: UIViewController, URLSessionDelegate, URLSessionDat

func getObject() -> Void {
let getObjectReq: OSSGetObjectRequest = OSSGetObjectRequest()
getObjectReq.bucketName = OSS_BUCKET_PUBLIC;
getObjectReq.bucketName = OSS_BUCKET_PRIVATE;
getObjectReq.objectKey = OSS_IMAGE_KEY;
getObjectReq.downloadProgress = { (bytesWritten: Int64,totalBytesWritten : Int64, totalBytesExpectedToWrite: Int64) -> Void in
print("bytesWritten:\(bytesWritten),totalBytesWritten:\(totalBytesWritten),totalBytesExpectedToWrite:\(totalBytesExpectedToWrite)");
Expand All @@ -152,7 +152,7 @@ class OSSRootViewController: UIViewController, URLSessionDelegate, URLSessionDat

func getImage() -> Void {
let getObjectReq: OSSGetObjectRequest = OSSGetObjectRequest()
getObjectReq.bucketName = OSS_BUCKET_PUBLIC;
getObjectReq.bucketName = OSS_BUCKET_PRIVATE;
getObjectReq.objectKey = objectKeyTF.text!;
getObjectReq.xOssProcess = "image/resize,m_lfit,w_100,h_100";
getObjectReq.downloadProgress = { (bytesWritten: Int64,totalBytesWritten : Int64, totalBytesExpectedToWrite: Int64) -> Void in
Expand Down Expand Up @@ -213,7 +213,7 @@ class OSSRootViewController: UIViewController, URLSessionDelegate, URLSessionDat
}

let request = OSSHeadObjectRequest()
request.bucketName = OSS_BUCKET_PUBLIC
request.bucketName = OSS_BUCKET_PRIVATE
request.objectKey = objectKeyTF.text!

let task: OSSTask = mClient.headObject(request)
Expand Down Expand Up @@ -396,7 +396,7 @@ class OSSRootViewController: UIViewController, URLSessionDelegate, URLSessionDat

func sequentialMultipartUpload() {
let request = OSSResumableUploadRequest()
request.bucketName = OSS_BUCKET_PUBLIC;
request.bucketName = OSS_BUCKET_PRIVATE;
request.objectKey = "sequential-swift-multipart";
request.uploadingFileURL = Bundle.main.url(forResource: "wangwang", withExtension: "zip")!
request.deleteUploadIdOnCancelling = false
Expand Down
16 changes: 8 additions & 8 deletions OSSSwiftDemo/OSSSwiftDemo/Classes/OSSSwiftGlobalDefines.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

import Foundation

let OSS_ACCESSKEY_ID: String = "OSS_ACCESSKEY_ID"
let OSS_SECRETKEY_ID: String = "OSS_SECRETKEY_ID"
let OSS_BUCKET_PUBLIC: String = "huaixu-private"
let OSS_BUCKET_PRIVATE: String = "huaixu-private"
let OSS_ENDPOINT: String = "http://oss-cn-shenzhen.aliyuncs.com"
let OSS_ACCESSKEY_ID: String = "access_key_id"
let OSS_SECRETKEY_ID: String = "access_key_secret"
let OSS_BUCKET_PUBLIC: String = "public-bucket"
let OSS_BUCKET_PRIVATE: String = "private-bucket"
let OSS_ENDPOINT: String = "http://oss-cn-region.aliyuncs.com"
let OSS_MULTIPART_UPLOADKEY: String = "multipart"
let OSS_RESUMABLE_UPLOADKEY: String = "resumable"
let OSS_CALLBACK_URL: String = "http://oss-demo.aliyuncs.com:23450"
let OSS_CNAME_URL: String = "https://hs.chenhongyu.cn"
let OSS_STSTOKEN_URL: String = "http://30.40.38.17:3015/sts/getsts"
let OSS_IMAGE_KEY: String = "zuozhu.jpeg"
let OSS_CNAME_URL: String = "http://www.cnametest.com/"
let OSS_STSTOKEN_URL: String = "http://*.*.*.*.****/sts/getsts"
let OSS_IMAGE_KEY: String = "testImage.png"
let OSS_CRC64_ENABLE: Bool = true
let OSS_CONTENT_TYPE: String = "Content-Type"
let OSS_CONTENT_LENGTH: String = "Content-Length"
Expand Down
66 changes: 66 additions & 0 deletions quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#快速开始

##1.部分仓库目录以及文件介绍

- **AliyunOSSiOSTests** 【测试用例源码】
- **AliyunOSSSDK** 【sdk源代码】
- **Example** 【OC版项目接入SDK的示例】
- **Images** 【文档中引用的图片】
- **OSSSwiftDemo** 【Swift版项目接入SDK的示例】
- **Scripts** 【搭建获取STS信息的本地服务器python代码】
- **Supporting Files** 【存放支持文件】
- AliyunOSSSDK.xcodeproj 【编译sdk源代码的工程文件】
- AliyunOSSSDK.xcworkspace 【包含了AliyunOSSSDK, OSSSwiftDemo, AliyunOSSiOSTests, Example等工程的工作区文件】
- AliyunOSSiOS.podspec 【用于支持Cocoapods引用的spec文件】
- buildiOSFramework.sh 【编译iOS版本的framework(同时i386,x86_64,armv7,arm64架构),生成好的framework文件存放在仓库根目录下的Products目录下】
- buildOSXFramework.sh 【编译Mac版本的framework,生成好的framework文件存放在仓库根目录下的Products目录下】
- CHANGELOG.txt 【版本变更记录信息】

##使用
**系统环境要求:**

1.***Mac***系统下安装***Xcode8***以上的版本,以及***Xcode Command Tools***

2.***安装python包管理工具[pip](https://pypi.org/project/pip/)***

```
//bash
sudo easy_install pip
```

3.***安装依赖的python库已经网络模块***

```
// 安装阿里云访问控制的sts授权库
pip install aliyun-python-sdk-sts
// 安装web模块
pip install web.py
```
如果在安装过程中遇到Permission denied的错误,您需要在执行相关命令前加上***```sudo```***,如***```sudo pip install aliyun-python-sdk-sts```***

1.打开工作区文件
![workspace](https://github.com/aliyun/aliyun-oss-ios-sdk/blob/master/Images/workspace.png)

2.如果您要尝试iOS的OC版本的示例工程进行接口调用,需要修改***Scripts***目录下的sts.py文件
![account_info](https://github.com/aliyun/aliyun-oss-ios-sdk/blob/master/Images/account_info.png)

然后启动本地sts授权服务服务器
***```python Scripts/httpserver.py 本机ip:端口号```***

其中***本机ip******端口号***需要您自行设置

3.选择您需要用的scheme
![schemes](https://github.com/aliyun/aliyun-oss-ios-sdk/blob/master/Images/schemes.png)

4.如果您选择的scheme是AliyunOSSSDK-iOS-Example,您需要修改OSSTestMacros.h中的信息
![schemes](https://github.com/aliyun/aliyun-oss-ios-sdk/blob/master/Images/testmacros.png)

如果选择的scheme是OSSSwiftDemo,那么您需要修改的是OSSSwiftGlobalDefines.swift中的信息
![swiftglobalconfig](https://github.com/aliyun/aliyun-oss-ios-sdk/blob/master/Images/swiftglobalconfig.png)

接下来即可体验demo

0 comments on commit 22652b7

Please sign in to comment.