Try any Node.js package right in your browser

Share this code:

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including react-native-michael-aliyun-oss with all npm packages installed. Try it out:

react-native-michael-aliyun-oss v1.0.3

React Native SDK for aliyun object storage service

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

解决react-native-0.59.2 android release 打包报错问题

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.

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.

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。

asyncDeleteObject

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-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

npm run start

open Example/android ,compile and run with Android Studio.The effect is as follows

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.