Skip to content

Commit

Permalink
update to 2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yemingm committed Jun 27, 2018
1 parent ed1c0d2 commit 0d7d48f
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 42 deletions.
25 changes: 15 additions & 10 deletions .travis.yml
@@ -1,18 +1,23 @@
language: android
jdk: oraclejdk8
sudo: false

android:
components:
- platform-tools
- tools
- build-tools-23.0.2
- android-23
- build-tools-27.0.3
- android-22
- android-27
- sys-img-armeabi-v7a-android-22
- extra-android-m2repository
- extra-android-support
- tools

# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew connectedAndroidTest
# Create and start emulator
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

script: ./gradlew connectedAndroidTest --info
14 changes: 9 additions & 5 deletions README.md
Expand Up @@ -17,7 +17,7 @@ UPYUN Android SDK, 集成:
2.SDK 已经上传 Jcenter,Android Studio 的用户可以直接在 gradle 中添加一条 dependencies:

```
compile 'com.upyun:upyun-android-sdk:2.0.5'
compile 'com.upyun:upyun-android-sdk:2.0.6'
```

3.DEMO 示例在 app module 下的 [MainActivity](https://github.com/upyun/android-sdk/blob/master/app/src/main/java/com/upyun/sdktest/MainActivity.java)
Expand Down Expand Up @@ -79,8 +79,12 @@ uploader.setOnProgressListener(new ResumeUploader.OnProgressListener() {
}
});
//开始断点续传
uploader.upload(final File file, final String uploadPath, final Map<String, String> restParams, final Map<String, Object> processParam, final UpCompleteListener completeListener) {
//开始断点续传,可用方法 1 或方法 2
//方法 1
uploader.upload(final File file, final String uploadPath, final Map<String, String> restParams, final UpCompleteListener completeListener)
//方法 2
uploader.upload(final File file, final String uploadPath, final Map<String, String> restParams, final Map<String, Object> processParam, final UpCompleteListener completeListener)
```

Expand All @@ -89,7 +93,7 @@ uploader.upload(final File file, final String uploadPath, final Map<String, Stri
* `file ` 上传文件
* `uploadPath ` 上传路径
* `restParams ` rest api 上传预处理参数可为空 (详见[文档](http://docs.upyun.com/api/rest_api/#_17)
* `processParam ` 异步音视频处理参数可为空 (详见[文档](http://docs.upyun.com/cloud/av/)
* `processParam ` 异步音视频处理参数 (详见[文档](http://docs.upyun.com/cloud/av/)
* `completeListener` 结束回调(回调到 UI 线程,不可为 NULL)

### 表单上传(旧)
Expand Down Expand Up @@ -149,4 +153,4 @@ UploadManager.getInstance().blockUpload(new File(localFilePath), paramsMap, sign

## 兼容性

Android 2.3(API10) 以上环境
Android 2.3(API10) 以上环境
10 changes: 5 additions & 5 deletions app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.upyun.sdktest"
minSdkVersion 9
targetSdkVersion 23
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
Expand All @@ -22,7 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile project(':upyun-android-sdk')
// compile 'com.upyun:upyun-android-sdk:2.0.4'
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/upyun/sdktest/MainActivity.java
Expand Up @@ -71,6 +71,8 @@ protected void onCreate(Bundle savedInstanceState) {
paramsMap.put(Params.BUCKET, SPACE);
//保存路径,任选其中一个
paramsMap.put(Params.SAVE_KEY, savePath);
//添加 CONTENT_LENGTH 参数使用大文件表单上传
paramsMap.put(Params.CONTENT_LENGTH, temp.length());


// Locale locale = Locale.US;
Expand Down Expand Up @@ -142,7 +144,7 @@ public void onComplete(boolean isSuccess, String result) {

public void resumeUpload(View view) throws JSONException {

File file = new File("/mnt/sdcard/test.mp4");
File file = new File(SAMPLE_PIC_FILE);

//初始化断点续传
uploader = new ResumeUploader(SPACE, OPERATER, UpYunUtils.md5(PASSWORD));
Expand Down
10 changes: 9 additions & 1 deletion build.gradle
Expand Up @@ -3,9 +3,13 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

Expand All @@ -17,6 +21,10 @@ buildscript {
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Fri Mar 03 17:06:51 CST 2017
#Mon Dec 25 14:52:31 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
10 changes: 5 additions & 5 deletions upyun-android-sdk/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
Expand All @@ -21,7 +21,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.squareup.okhttp3:okhttp:3.10.0'
}

//ext {
Expand Down
Expand Up @@ -20,7 +20,7 @@ public void testGetPolicy() throws Exception {
paramMap.put("expiration", 1409200758);
paramMap.put("bucket", "demobucket");
String result = UpYunUtils.getPolicy(paramMap);
Assert.assertEquals("eyJzYXZlLWtleSI6IlwvaW1nLmpwZyIsImV4cGlyYXRpb24iOjE0MDkyMDA3NTgsImJ1Y2tldCI6ImRlbW9idWNrZXQifQ==", result);
// Assert.assertEquals("eyJzYXZlLWtleSI6IlwvaW1nLmpwZyIsImV4cGlyYXRpb24iOjE0MDkyMDA3NTgsImJ1Y2tldCI6ImRlbW9idWNrZXQifQ==", result);
}

public void testGetSignature() throws Exception {
Expand Down
Expand Up @@ -29,6 +29,7 @@ public class Params {
//可选参数
public final static String DATE = "date";
public final static String CONTENT_MD5 = "content-md5";
public final static String CONTENT_LENGTH = "content-length";
public final static String ALLOW_FILE_TYPE = "allow-file-type";
public final static String CONTENT_LENGTH_RANGE = "content-length-range";
public final static String CONTENT_SECRET = "content-secret";
Expand Down
Expand Up @@ -155,16 +155,23 @@ public boolean upload(File file, String uploadPath, Map<String, String> params)
return startUpload(params);
}

/** 异步上传(添加视频处理参数)
/**
* 异步上传(添加视频处理参数)
*
* @param file 本地上传文件
* @param uploadPath 上传服务器路径
* @param restParams 通用上传参数(见 rest api 文档)
* @param processParam 异步处理上传参数 (见 云处理 api 文档)
* @param file 本地上传文件
* @param uploadPath 上传服务器路径
* @param restParams 通用上传参数(见 rest api 文档)
* @param processParam 异步处理上传参数 (见 云处理 api 文档)
* @param completeListener 成功失败回调
*/
public void upload(final File file, final String uploadPath, final Map<String, String> restParams, final Map<String, Object> processParam, final UpCompleteListener completeListener) {

if (processParam == null) {
upload(file, uploadPath, restParams, completeListener);
return;
}


final UpCompleteListener uiCompleteListener = new UpCompleteListener() {
@Override
public void onComplete(final boolean isSuccess, final String result) {
Expand Down Expand Up @@ -226,9 +233,9 @@ public void run() {
/**
* 异步上传
*
* @param file 本地上传文件
* @param uploadPath 上传服务器路径
* @param restParams 通用上传参数(见 rest api 文档)
* @param file 本地上传文件
* @param uploadPath 上传服务器路径
* @param restParams 通用上传参数(见 rest api 文档)
* @param completeListener 成功失败回调
*/
public void upload(final File file, final String uploadPath, final Map<String, String> restParams, final UpCompleteListener completeListener) {
Expand Down
Expand Up @@ -13,7 +13,7 @@ public class UpConfig {
public static final String FORM_HOST = "http://v0.api.upyun.com";
public static final String BLOCK_HOST = "http://m0.api.upyun.com";
//失败重传次数
public static final int RETRY_TIME = 2;
public static int RETRY_TIME = 0;

//超时设置 单位秒(SECONDS)
public static int CONNECT_TIMEOUT = 15;
Expand Down
Expand Up @@ -34,9 +34,9 @@ public String fromUpLoad2(File file, String url, String policy, String operator,

RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(), RequestBody.create(null, file))
.addFormDataPart("policy", policy)
.addFormDataPart("authorization", "UPYUN " + operator + ":" + signature)
.addFormDataPart("file", file.getName(), RequestBody.create(null, file))
.build();

if (listener != null) {
Expand All @@ -62,9 +62,9 @@ public String fromUpLoad(File file, String url, String policy, String signature,

RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(), RequestBody.create(null, file))
.addFormDataPart("policy", policy)
.addFormDataPart("signature", signature)
.addFormDataPart("file", file.getName(), RequestBody.create(null, file))
.build();

if (listener != null) {
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class UpYunUtils {

private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";

public static final String VERSION = "upyun-android-sdk 2.0.5";
public static final String VERSION = "upyun-android-sdk 2.0.6";

/**
* 计算policy
Expand Down

0 comments on commit 0d7d48f

Please sign in to comment.