alioss-react-native
v1.0.2
Published
aliyun oss for react native
Readme
alioss-react-native
AliYun oss for react native,支持 Android + iOS,是aliyun-oss-react-native的问题修复版本
Environment
- React Native > 0.60
- Node 8.0 or above
- iOS 10.0 or above
- Android 4.4 or above
Table of Contents
Installation
npm install alioss-react-native
or
yarn add alioss-react-nativeiOS
cd ios
pod installAndroid
do nothing (The Gradle will automatically import alioss-react-native )
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 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
Usage
import { AliyunOSS } from "alioss-react-native";Main type
OSSinit
declare type OSSinit = {
maxRetryCount: number;
timeoutIntervalForRequest: number;
timeoutIntervalForResource: number;
};OssListOptions
declare type OssListOptions = {
prefix: string;
marker?: string;
maxKeys?: string;
delimiter?: string;
};
AppendType
declare type AppendType = {
appendPosition: number;
contentType: string;
contentMd5: string;
contentEncoding: string;
contentDisposition: string;
};enableDevMode
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 = "https://xxx"
const configuration = {
maxRetryCount: 3,
timeoutIntervalForRequest: 30,
timeoutIntervalForResource: 24 * 60 * 60
};
AliyunOSS. initWithPlainTextAccessKey(accessKey: string, secretKey: string, endPoint: string, configuration?: OSSinit): void;initWithSecurityToken
init client with SecurityToken
AliyunOSS.initWithSecurityToken(securityToken: string, accessKey: string, secretKey: string, endPoint: string, configuration?: OSSinit): void;asyncUpload
AliyunOSS.asyncUpload(bucketName: string, objectKey: string, filepath: string, options?: {}): Promise<any>;asyncAppendObject
AliyunOSS.asyncAppendObject(bucketName: string, objectKey: string, filepath: string, options?: AppendType): Promise<any>;asyncResumableUpload
AliyunOSS.asyncResumableUpload(bucketName: string, objectKey: string, filepath?: string, options?: {}): Promise<any>;initMultipartUpload
AliyunOSS.initMultipartUpload(bucketName: string, objectKey: string): Promise<any>;multipartUpload
//uploadId is the value When call initMultipartUpload ,success callback return
AliyunOSS.abortMultipartUpload(bucketName: string, objectKey: string, uploadId: string): Promise<any>;listParts
AliyunOSS.listParts(bucketName: string, objectKey: string, uploadId: string): Promise<any>;abortMultipartUpload
AliyunOSS.abortMultipartUpload(bucketName: string, objectKey: string, uploadId: string): Promise<any>;asyncDownload
AliyunOSS. asyncDownload(bucketName: string, objectKey: string, filepath?: string, options?: {
'x-oss-process': string;
}): Promise<any>;asyncCreateBucket
AliyunOSS. asyncCreateBucket(bucketName: string, acl: string | undefined, region: string):asyncGetBucketACL
AliyunOSS.asyncGetBucketACL(bucketName: string): Promise<any>;asyncListBuckets
AliyunOSS.asyncListBuckets(): Promise<any>;asyncDeleteBucket
AliyunOSS.asyncDeleteBucket(bucketName: string): Promise<any>;asyncHeadObject
AliyunOSS.asyncHeadObject(bucketName: string, objectKey: string): Promise<any>;asyncListObjects
list objects in some conditions
parameters:
- name {String} bucket name
- options {Object}
- [delimiter] {String}
- [prefix] {String} search buckets using
prefixkey - [marker] {String} search start from
marker, includingmarkerkey - [maxKeys] {String|Number} max buckets, default is
100, limit to1000
AliyunOSS.asyncListObjects(bucketName: string, options?: OssListOptions | undefined): Promise<any>;doesObjectExist
AliyunOSS.doesObjectExist(bucketName: string, objectKey: string): Promise<any>;asyncCopyObject
AliyunOSS.asyncCopyObject(srcBucketName: string, srcObjectKey: string, desBucketName: string, destObjectKey: string, options: any): Promise<any>;asyncDeleteObject
AliyunOSS. asyncDeleteObject(bucketName: string, objectKey: string): Promise<any>;Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
- MIT
