Giter Club home page Giter Club logo

aliyun-oss-react-native's Introduction

Alibaba Cloud OSS SDK for React Native

Introduction

This document mainly describes how to install and use the OSS React Native SDK. This document assumes that you have already activated the Alibaba Cloud OSS service and created an AccessKeyID and an AccessKeySecret. In the document, ID refers to the AccessKeyID and KEY indicates the AccessKeySecret. If you have not yet activated or do not know about the OSS service, log on to the OSS Product Homepage for more help.

Lanaguage

  • JavaScript、JAVA、Objective-C

Environment requirements

  • Android 2.3 or above
  • IOS 8.0 or above
  • You must have registered an Alibaba Cloud account with the OSS activated.
  • Node 8.0 or above
  • React Native 0.44.0 or above

Table of Contents

Installation

NOTE: THIS PACKAGE IS NOW BUILT FOR REACT NATIVE 0.40 OR GREATER

  • npm
npm install aliyun-oss-react-native --save
  • yarn
yarn install aliyun-oss-react-native --save

Automatic Installation

run react-native link in the react native project

react-native link aliyun-oss-react-native

Note:for suppport IPv6-Only networkd,you need to require :

1. libresolv.tbd
2. CoreTelephony.framework
3. SystemConfiguration.framework

Manual Installation

iOS

  • CocoaPods
pod 'aliyun-oss-react-native', :path => '../node_modules/aliyun-oss-react-native'
  • no CocoaPods
  1. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to <...> Go to node_modulesaliyun-oss-react-nativeios ➜ select RNAliyunOSS.xcodeproj
  2. Add libRNAliyunOSS.a to Build Phases -> Link Binary With Libraries
  3. In XCode, in the project navigator, right click FrameworksAdd Files to [your project's name]. Go to node_modulesaliyun-oss-react-nativeAliyunSDK. Add AliyunOSSiOS.framework, and select Copy items if needed in the pop-up box.

Android

  1. Add the following lines to android/settings.gradle:
include ':react-native-react-sdk'
project(':react-native-react-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/aliyun-oss-rn-sdk/android')
  1. Add the compile line to the dependencies in android/app/build.gradle:
dependencies {
  compile project(':aliyun-oss-react-native')
}
  1. Add the required permissions in AndroidManifest.xml:
   <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
   <uses-permission android:name="android.permission.CAMERA" />
  1. Add the import and link the package in MainApplication.java:
import com.reactlibrary.RNAliyunOssPackage;

 public class MainApplication extends Application implements ReactApplication {
  @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new RNAliyunOssPackage()
    );
  }
}

Usage

Now ,all the API returns Promise Object exception init OSS Client API and enableDevMode API,so you can use ES6 async await or promise().then(/**/).catch(/**/),we take asyncUpload interface as an example.

  • step-1:import AliyunOSS
import AliyunOSS from 'aliyun-oss-react-native'
  • step-2:open debug mode (optional)
AliyunOSS.enableDevMode();
  • step-3:init configuration(optional)
const configuration = {
   maxRetryCount: 3,
   timeoutIntervalForRequest: 30,
   timeoutIntervalForResource: 24 * 60 * 60
};
  • step-4:init OSS Client,we provide 4 ways to init OSS Client. here we recommend initWithServerSTS
const endpoint = "xxxx.aliyuncs.com"

AliyunOSS.initWithServerSTS("/***http://ip:port/****/",endPoint, configuration)

Note:We provide auth server with node shell in Script folder,you can run command link this.

  1. npm istall
  2. modify accessKeyId and accessKeySecret in the config.js
  3. node index.js,port is defalut 9000,The auth server is like (http|https)://ip.com:9000/
  • step-5:
    <!-- note:filepath must start with file:/// -->
    AliyunOSS.asyncUpload(bucketname, objectkey, filePath).then( (res) => {
        <!-- you can see the log with React Native debugg tools or XCode 、Android studio console -->
        console.log(res)
    }).catch((error)=>{
        console.log(error)
    })
    <!-- addEventlistener uploadPross-->
   const downloadProgress = p => console.log(p.currentSize / p.totalSize);
   AliyuOSS.addEventListener('uploadProgress', downloadProgress);

api

This section describes the APIs that are currently implemented and partially supported by the React Native SDK. These APIs mainly cover log management, bucket management, object management, authorization, file upload, and download. Follow-up to improve the relevant API and BUG repair. API list is as follows

API Android iOS
enableDevMode Y Y
initWithPlainTextAccessKey Y Y
initWithSigner Y Y
initWithSecurityToken Y Y
initWithServerSTS Y Y
asyncUpload Y Y
initMultipartUpload Y Y
multipartUpload Y Y
listParts Y Y
abortMultipartUpload Y Y
asyncDownload Y Y
asyncCreateBucket Y Y
asyncGetBucketACL Y Y
asyncListBuckets Y Y
asyncDeleteBucket Y Y
asyncHeadObject Y Y
asyncListObjects Y Y
doesObjectExist Y Y
doesObjectExist Y Y
asyncDeleteObject Y Y

enableDevMode

open dev log,please refer to the code

AliyunOSS.enableDevMode()

initWithPlainTextAccessKey

init auth client with accessKeyId and accessKeySecret,please refer to the code.you can use ,but we do not suggest use it。

const endPoint = "XXX"
const configuration = {
    maxRetryCount: 3,
    timeoutIntervalForRequest: 30,
    timeoutIntervalForResource: 24 * 60 * 60
 };
AliyunOSS.initWithPlainTextAccessKey(accessKey, secretKey, endPoint, configuration);

initWithSigner

init auth client the sign

AliyunOSS.initWithSigner(signature, accessKey, endPoint, configuration);

initWithSecurityToken

init client with SecurityToken

AliyunOSS.initWithSecurityToken(SecurityToken, accessKeyId, accessKeySecret, endPoint, configuration);


### initWithServerSTS

init auth client with local auth server

```javascript
AliyunOSS.initWithServerSTS(/*local auth server*/, endPoint, configuration);

asyncUpload

AliyunOSS.asyncUpload(bucketname, objectKey, filepath).then().catch()

asyncAppendObject

asyncResumableUpload

initMultipartUpload

 AliyunOSS.initMultipartUpload(bucketname,objectkey).then((e) => {
      //e is uploadId
      console.log(e)
    }).catch((error) => {
      console.log(error)
 })

multipartUpload

//uploadId is  the value When call initMultipartUpload ,success callback return
AliyunOSS.multipartUpload(multipartBucket,mulitipartObjectKey,uploadId,filepath).then((res)=>{
    Alert.alert("success");
  }).catch((e) => {
    Alert.alert("fail");
  })

listParts

AliyunOSS.listParts(multipartBucket,multipartObjectKey,upoadId).then((e)=>{
    Alert.alert("onListParts"+e)
  }).catch((e)=>{
    Alert.alert("onListPartsError")
 })

abortMultipartUpload

 AliyunOSS.abortMultipartUpload(multipartBucket,multipartBucket,uploadId).then((e)=>{
    Alert.alert("abort success");
  }).catch((e)=>{
    Alert.alert("abort fali");
  })

asyncDownload

 // xxx is the image process option
 AliyunOSS.asyncDownload(bucketname,objectkey,{"x-oss-process":'xxxx'}).then((e) => {
    console.log(e)
  }).catch((e)=>{
    console.log(e)
  })

asyncCreateBucket

 AliyunOSS.asyncCreateBucket('tyluoluo','private','oss-cn-zhangjiakou').then((e) => {
    console.log(e)
  }).catch((e)=>{
     console.log(e)
  })

asyncGetBucketACL

 AliyunOSS.asyncGetBucketACL('luozhang002').then((e) => {
    console.log(e)
  }).catch((e)=>{
    console.log(e)
  })

asyncListBuckets

AliyunOSS.asyncListBuckets().then((e) => {
    console.log(e)
  }).catch((e) => {
    console.log(e)
  })

asyncDeleteBucket

 AliyunOSS.asyncDeleteBucket("tyluoluo").then((e) => {
    console.log(e)
  }).catch((e) => {
    console.log(e)
  })

asyncHeadObject

 AliyunOSS.asyncHeadObject('luozhang002','yanxing').then((e)=>{
    console.log(e)
  }).catch((e)=> {
     console.log(e)
 })

asyncListObjects

list objects in some conditions

parameters:

  • name {String} bucket name
  • options {Object}
    • [delimiter] {String}
    • [prefix] {String} search buckets using prefix key
    • [marker] {String} search start from marker, including marker key
    • [max-keys] {String|Number} max buckets, default is 100, limit to 1000
 AliyunOSS.asyncListObjects('luozhang002', {
    prefix:'xxxx'
}).then((e)=>{
    console.log(e)
  }).catch((e)=>{
     console.log(e)
  })

doesObjectExist

 AliyunOSS.doesObjectExist('luozhang001','xx.png').then( (e) => {
    console.log(e)
  }).catch((e) => {
    console.log(e)
  })

asyncCopyObject

 AliyunOSS.asyncCopyObject('luozhang001',"2.png","luozhang002","sbsbsb").then( (e) => {
    console.log(e)
  }).catch((e)=>{
    console.log("xxxx")
    console.log(e)
  })

asyncDeleteObject

 AliyunOSS.asyncDeleteObject('luozhang001','2.png').then((e)=>{
    Alert.alert(e)
  }).catch((e)=>{
    console.log(e)
  })

DEMO

In the repository, we prodive RN SDK DEMO in the Example folder including andriod and ios,Example/android provide the android demo;Example/iOS provide the ios demo.Welcome to join us, how to run the Example ?

  • step-1:clone the project and install some dependencies
1. git clone https://github.com/aliyun/aliyun-oss-react-native.git
2. cd Example
3. npm install
  • step-2:start local auth server and modify the URL in initWithServerSTS function of Example/App.js,Server address must begin with ip,of cource you can refer to the scrpts folder we provied.defalut port is 9000
1. cd script/sts-app-server-node
2. node index.js
  • step-3:run the project
  1. npm run start
  2. open Example/android ,compile and run with Android Studio.The effect is as follows

  1. open Example/NativeAddRN ,compile and run with XCode,The effect is as follows

F&Q

  • Due to the complexity of React Native's own environment on the iOS side,it ofen occur differrent errors, please go to stackoverflow
  • close proxy
  • Sometimes,you can not see the ui in the debugging mode of the Android Studio Envrionment, please delete the Build folder under the project file and then recompile

Join

Now, React Native SDK is in the initial stage. When the developers use React Native API, any problem can be raised to the official warehouse for issue or PR. We will deal with it in time. Wecome much more developers to join us to serve customers and developers that who use aliyun storage services To better serve customers and developers who use aliyun storage services.You can refer to the following documentation.

License

  • MIT

Contact us

Future

in the future, Continuously optimizing code documentation、add interfaces 、fix bugs, etc.

Documentation

enhancement

aliyun-oss-react-native's People

Contributors

luozhang002 avatar zephyrpersonal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aliyun-oss-react-native's Issues

反馈几个问题

1.中文readme文档中的

AliyunOSS.initWithSecurityToken(/*local auth server*/, endPoint, configuration);

应该是

AliyunOSS.initWithServerSTS("/***http://ip:port/****/",endPoint, configuration)

2.使用

AliyunOSS.asyncUpload(bucketname, objectKey, filepath).then((res) => {
// 这里并不能判断是否上传成功
// 还需要根据返回的res判断 httpResponseCode是否为200
// 当为200状态码的时候才是上传成功
}).catch()

Not add

  1. libresolv.tbd
  2. CoreTelephony.framework
  3. SystemConfiguration.framework
    How do I add these? Can you explain it briefly?

上传回调无效,不走

const downloadProgress = p => console.log(p.currentSize / p.totalSize);
AliyuOSS.addEventListener('uploadProgress', downloadProgress);

不走downloadProgress回调

AliyunOSS.initWithServerSTS don't support Header

在鉴权的时候,鉴权服务器需要客户端token(sessionId)来判定这个人是谁,所以需要在设置 AliyunOSS.initWithServerSTS 的时候来提供客户端Token。是否能在未来进行支持?

asyncUpload上传成功返回数据问题

asyncUpload 上传成功,返回的数据类型,怎么拿到url
返回结果--- <OSSTask: 0x6000022dc1c0; completed = YES; cancelled = NO; faulted = NO; result = OSSResult<0x6000023a3500> : {httpResponseCode: 200, requestId: 5BD96FE20C51712121F47F85, httpResponseHeaderFields: {
Connection = "keep-alive";
"Content-Length" = 0;
"Content-MD5" = "xBqgoHuQvuTNX0u+SFPMSA==";
Date = "Wed, 31 Oct 2018 09:03:31 GMT";
Etag = ""C41AA0A07B90BEE4CD5F4BBE4853CC48"";
Server = AliyunOSS;
"x-oss-hash-crc64ecma" = 3024406496928251140;
"x-oss-request-id" = 5BD96FE20C51712121F47F85;
"x-oss-server-time" = 184;
}, local_crc64ecma: (null)}>

Example 中的ios 例子直接无法编译通过

clone 项目后执行,npm install后,在xcode中启动,无法找到 -lRCTBlob这个依赖库,并且RCTBlob.xcodeproj 也是缺失的

ld: library not found for -lRCTBlob
clang: error: linker command failed with exit code 1 (use -v to see invocation)

./gradlew assembleRelease 失败

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':aliyun-oss-react-native:verifyReleaseResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 5s

这个endpoint 该填什么?

'http://verzqli.oss-cn-beijing.aliyuncs.com';
比如这样一个链接 我看你的例子
const endPoint = 'oss-cn-beijing.aliyuncs.com';

const familyserver = "http://verzqli";
AliyunOSS.initWithServerSTS(familyserver,endPoint, configuration)
这样写
3blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:84148 Error: Can't get a federation token
[ErrorMessage]: Can't get a federation token
at createErrorFromErrorData (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2043)
at blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:1995
at MessageQueue.__invokeCallback (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2437)
at blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2182
at MessageQueue.__guardSafe (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2350)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2181)
at debuggerWorker.js:70
报这个错,请问什么原因?

Upload file failed with error: "framesToPop":1,"code":"EUNSPECIFIED"

configuration:
const AliOSS = {
    endpoint: 'oss-cn-hongkong.aliyuncs.com',
    config: {
        maxRetryCount: 3,
        timeoutIntervalForRequest: 30,
        timeoutIntervalForResource: 24 * 60 * 60
    },
    securityToken: '', // get from server
    accessKey: '',
    secretKey: '',
};

...

AliyunOSS.enableDevMode();
AliyunOSS.initWithSecurityToken(r.securityToken, r.accessKeyId, r.accessKeySecret, AliOSS.endpoint, AliOSS.config)
AliyunOSS.addEventListener('uploadProgress', (p) => {
	let per = parseInt(p.currentSize / p.totalSize * 10);
	if (per !== logCount) {
		logCount = per;
		JLLog('uploadProgress ' + per);
	}
});
use like this :
AliyunOSS.asyncUpload('bwoil-file', 'jonglim/hand-test' + rendom++, source[0].uri).then((res) => {
	JLLog({ AliyunOSS: res })
}).catch((error) => {
	JLLog({ AliyunOSS: error })
})
log
07-13 17:18:14.924  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 1
07-13 17:18:14.932  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 2
...
07-13 17:18:14.966  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 9
07-13 17:18:14.970  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 10
07-13 17:18:15.019  7028 12904 I ReactNativeJS: >> NewPostScreen.js << {"AliyunOSS":{"framesToPop":1,"code":"EUNSPECIFIED"}}

Anyone know what's wrong with this?

Android虚拟机 上传失败 Can't get a federation token

环境是: android 虚拟机;

"aliyun-oss-react-native": "^1.0.0-alpha.5",
"react-native": "0.55.4",
"react-native-image-picker": "^0.26.10",

采用 initWithPlainTextAccessKey 方式 初始化的 AliyunOSS 调用 asyncUpload API上传, 在IOS下一切正常, android 下 出现异常,异常信息 [Info] 07-17 14:25:19.988 4873 5287 I ReactNativeJS: { [Error: Can't get a federation token 07-17 14:25:19.988 4873 5287 I ReactNativeJS: [ErrorMessage]: Can't get a federation token] framesToPop: 1, code: 'EUNSPECIFIED' }

我增加了

AliyunOSS.addEventListener('uploadProgress', (p) => {
      console.log('here?');
    });

好像这个方法都没有进来

参数格式如下

[Info] 07-17 15:31:38.498  4231  5445 I ReactNativeJS: 'bucketName', 'mxb-bucket'
07-17 15:31:38.499  4231  5445 I ReactNativeJS: 'objectKey', '9b00b88bb0e565ef153181269835840383image-0459516f-6e3d-4891-84c9-387c4e89a350.jpg'
07-17 15:31:38.499  4231  5445 I ReactNativeJS: 'url', 'file:///storage/emulated/0/Android/data/com.app_merchant_tao_mian_xi/files/Pictures/image-0459516f-6e3d-4891-84c9-387c4e89a350.jpg'

SDK的filepath规则

请问asyncUpload方法的filepath应该传什么值?为何使用绝对路径会报错?

image

expo 不兼容

我使用的是expo,安装aliyun-oss-react-native之后提示:
[ts]
Could not find a declaration file for module 'aliyun-oss-react-native'. 'h:/projectNew/client/node_modules/aliyun-oss-react-native/index.js' implicitly has an 'any' type.
Try npm install @types/aliyun-oss-react-native if it exists or add a new declaration (.d.ts) file containing declare module 'aliyun-oss-react-native'; [7016]
module "h:/projectNew/client/node_modules/aliyun-oss-react-native/index"

图片上传完成之后地址问题

https://yesdoctor.oss-cn-hongkong.aliyuncs.com/124546576856.jpg?Expires=1534305866&OSSAccessKeyId=TMP.AQF2kTi--E1BDx-PXWXuk8nl_g6pzUF3L2LoRFn5X3T7uld42AX2m0fq_o7OADAtAhUA1CbV58CmJ1KSt42-QIoylZ7NouwCFHFTuVWfeEsFu58XknkSXmYhwciv&Signature=5Xz1eF0Vh2Y4C4mDyFE6FvDXkwY%3D

上面是我上传成功之后的图片地址,?号之前的objectKey我可以理解,但是问号之后的Expires自动加上去的吗???如何可以去除掉,我是使用的initWithSecurityToken授权的方式,也请你写一下configuration这个参数的文档说明,谢谢

iOS build失败

error:'utility' file not found
error:Expected identifier or '('

构建方式:三部曲,library添加
rn版本:0.56.0

qq20180823-161227 2x

qq20180823-161302 2x

qq20180823-161319 2x

bug: asyncListObjects 接口在RNAliyunOSS+OBJECT.m 中存在错误

`if([options objectForKey:@"delimiter"]) {
getBucket.delimiter = [options objectForKey:@"delimiter"];
}

if([options objectForKey:@"marker"]) {
    getBucket.marker = [options objectForKey:@"marker"];
}

if([options objectForKey:@"prefix"]) {
    getBucket.prefix = [options objectForKey:@"prefix"];
}

if([options objectForKey:@"maxkeys"]) {
    getBucket.maxKeys = [[options objectForKey:@"maxkeys"] intValue];
}`

这一块是修改后的代码,望更新!

Manifest merger failed with multiple errors, see logs

系统:
android

配置:
1,
include ':aliyun-oss-react-native'
project(':aliyun-oss-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/aliyun-oss-react-native/android')
2,
//OSS
implementation project(':aliyun-oss-react-native')
3,
addPackage(new RNAliyunOssPackage());

compileSdkVersion 27
defaultConfig {
applicationId "com.qcec.valhalla"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    multiDexEnabled true

    ndk {
        abiFilters 'armeabi', 'x86',"armeabi-v7a"
    }
}

错误:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:524)
at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:143)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more

Document Issue

Replace react-native link to react-native link aliyun-oss-react-native , otherwise this command will gen exist duplicate link infomation.

iOS 无法编译通过 if Not using Cocoapods

项目中的ReactNative框架,没有使用Cocoapods导入。
然后配置aliyun-oss-react-native的时候,选择了“no CocoaPods”。

出现了几个问题, 我本地修改了,才能编译通过。

问题1: 导入RNAliyunOSS.xcodeproj,项目中只包含了RNAliyunOSS.h和RNAliyunOSS.m两个文件。
修改:把其他几个RNAliyunOSS+XXX.h和.m文件引入项目文件中

问题2:#import <RNAliyunOSS.h>导致编译失败
修改:由于直接在项目中引用RNAliyunOSS工程,所以<>的import方式会失败。修改成#import "RNAliyunOSS.h"

问题3:RNAliyunOSS+AUTH.m中, 无法找到OSSAuthCredentialProvider

RCT_EXPORT_METHOD(initWithServerSTS:(NSString *)server endPoint:(NSString *)endPoint configuration:(NSDictionary *)configuration){
    //直接访问鉴权服务器(推荐,token过期后可以自动更新)
    id<OSSCredentialProvider> credential = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:server];
    
    [self initConfiguration: configuration];

    self.client = [[OSSClient alloc] initWithEndpoint:endPoint credentialProvider:credential clientConfiguration:self.clientConfiguration];
}

修改:由于我们的RN项目中不需要使用initWithServerSTS,所以我先暂时把里面的代码给注释掉了。

希望能够帮助到其他小伙伴。

ios

编译ios,xcode中编译通过后,在iPhone x模拟器中调用initMultipartUpload接口没反应,也不报错,android正常

android No such file or directory

我剪切图片后上传时报错 No such file or directory,发现原因是 getFilePathFromURI 方法中没有正确获取缓存中的图片地址.

原图片地址

file:///storage/emulated/0/Android/data/com.awesomeapp/cache/1554800192263.jpg

通过 getFilePathFromURI 获取的图片地址

file:///storage/emulated/0/1554800192263.jpg // No such file or directory

应该直接把 file:// 去掉就能使用了.

    public static String getFilePathFromURI(Context context, Uri contentUri) {
        Log.d("oldfeel", "getFilePathFromURI: " + contentUri);
        //copy file and send new file path
        if(contentUri.toString().contains(context.getApplicationContext().getPackageName())){
            return contentUri.toString().substring(6);
        }

        String fileName = getFileName(contentUri);
        if (!TextUtils.isEmpty(fileName)) {
            File copyFile = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + fileName);
            FileUtils.copy(context, contentUri, copyFile);
            return copyFile.getAbsolutePath();
        }
        return null;
    }

Multipart upload should upload parts in parallel instead of serially

https://helpcdn.aliyun.com/document_detail/63262.html

要上传的文件切分成Part之后,
文件顺序是通过上传过程中指定的partNumber来确定的,实际执行中并没有顺序要求,
因此可以实现并发上传。具体的并发个数并不是越多速度越快,
要结合用户自身的网络情况和设备负载综合考虑。

Right now multipart upload for android and ios are implemented by uploading each part synchronously.
If one part fails, there is no retry, the entire upload fails.
This implementation does not receive many of the benefits of using multipart upload. Uploading in parallel should make the upload faster.

Do you know where I can find a parallel implementation multipart upload for android and ios?

IOS can't run with link aliyun-oss-react-native

Xcode version is 9.4.1

Step

react-native init Ex

cd ./Ex

npm i aliyun-oss-react-native

react-native link aliyun-oss-react-native

// add the tdb, and two framework in Link Frameworks and Librarys

// add the AliYunOssSDK.framework in Frameworks 

but can's run

image

Error

ld: framework not found AliyunOSSiOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)

RNAliyunOSS.initWithImplementedSigner is not a function

/**
* Initialize the OSS Client
* Mode: ImplementedSigner
*/
initWithImplementedSigner(signature, accessKey, endPoint, configuration = conf) {
RNAliyunOSS.initWithImplementedSigner(signature, accessKey, endPoint, configuration);
},
但是 RNAAliyunOssModule.java
只有 initWithSigner方法,没有 initWithImplementedSigner

源码asyncUpload有逻辑错误,请修正

源码
if (cursor == null) sourceFile = selectedVideoUri.getPath();
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
sourceFile = cursor.getString(column_index);

应该改为
if (cursor == null) {
sourceFile = selectedVideoUri.getPath();
}
else{
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
sourceFile = cursor.getString(column_index);
}

否则会进入catch逻辑中创建一个临时文件,而这个临时文件并不会在上传后删掉,麻烦修正下
谢谢

asyncListObjects接口未返回内容

OSS.initWithPlainTextAccessKey(accessKey, secretKey, endPoint);
        OSS.asyncListObjects(bucket, {
            delimiter: '/'
        }).then(res => {
            console.log(res);
            // Portal.remove(toastKey);
        }).catch(err => {
            debugger
        });

then、catch都未返回内容

说明文档很阿里

要不是为了吃饭...

<!-- log的查看可以通过React Native自带的调试工具也可通过XCode Log控制台进行查看 -->

你看看你们写的这什么玩意儿...比你们阿里飞燕系统的文档还草,人家团队好歹还写个不准确的或者不能用的。

授权访问?

类似于android的 String url = oss.presignConstrainedObjectURL("", "", 30 * 60);
接口。貌似还没写好??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.