mirror of
https://github.com/zhigang1992/aliyun-oss-react-native.git
synced 2026-01-12 17:12:29 +08:00
feat: extend asynclistObject support delimiter|marker|maxkeys to list object in Android
This commit is contained in:
@@ -16,51 +16,51 @@ import { styles } from '../CSS/global.js'
|
||||
export class ObjectManager extends Component {
|
||||
render() {
|
||||
return(
|
||||
<View style={styles.item}>
|
||||
<Text style={styles.description}>管理文件</Text>
|
||||
<View style={styles.detailitem}>
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncHeadObject")}
|
||||
title="asyncHeadObject"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.item}>
|
||||
<Text style={styles.description}>管理文件</Text>
|
||||
<View style={styles.detailitem}>
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncHeadObject")}
|
||||
title="asyncHeadObject"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncListObjects")}
|
||||
title="asyncListObjects"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncListObjects")}
|
||||
title="asyncListObjects"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncCopyObject")}
|
||||
title="asyncCopyObject"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncCopyObject")}
|
||||
title="asyncCopyObject"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"doesObjectExist")}
|
||||
title="doesObjectExist"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"doesObjectExist")}
|
||||
title="doesObjectExist"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncDeleteObject")}
|
||||
title="asyncDeleteObject"
|
||||
color="#841584"
|
||||
/>
|
||||
<View style={styles.button}>
|
||||
<Button style={styles.button}
|
||||
onPress={this.clickHandle.bind(this,"asyncDeleteObject")}
|
||||
title="asyncDeleteObject"
|
||||
color="#841584"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
)
|
||||
}
|
||||
clickHandle(e) {
|
||||
switch(e) {
|
||||
@@ -74,7 +74,9 @@ export class ObjectManager extends Component {
|
||||
|
||||
case "asyncListObjects" : {
|
||||
console.log("asyncListObjects")
|
||||
AliyunOSS.asyncListObjects('luozhang002').then((e) => {
|
||||
AliyunOSS.asyncListObjects('luozhang002',{
|
||||
prefix:'xxxx'
|
||||
}).then((e) => {
|
||||
console.log(e)
|
||||
}).catch((e)=>{
|
||||
console.log(e)
|
||||
@@ -108,5 +110,4 @@ export class ObjectManager extends Component {
|
||||
default :break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
README-CN.md
15
README-CN.md
@@ -334,8 +334,21 @@ AliyunOSS.asyncListBuckets().then((e) => {
|
||||
```
|
||||
### asyncListObjects
|
||||
|
||||
列举指定bucket下的objects
|
||||
|
||||
parameters:
|
||||
|
||||
- name {String} bucket name
|
||||
- options {Object}
|
||||
- [delimiter] {String} 用于对Object名字进行分组的字符。所有名字包含指定的前缀且第一次出现delimiter字符之间的object作为一组元素: CommonPrefixes。
|
||||
- [marker] {String} 设定结果从marker之后按字母排序的第一个开始返回。
|
||||
- [maxkeys] {Number} 限定此次返回object的最大数,如果不设定,默认为100,maxkeys取值不能大于1000。
|
||||
- [prefix] {String} 限定返回的object key必须以prefix作为前缀。注意使用prefix查询时,返回的key中仍会包含prefix。
|
||||
|
||||
```
|
||||
AliyunOSS.asyncListObjects('luozhang002').then((e)=>{
|
||||
AliyunOSS.asyncListObjects('luozhang002',{
|
||||
prefix:'xxxx'
|
||||
}).then((e)=>{
|
||||
console.log(e)
|
||||
}).catch((e)=>{
|
||||
console.log(e)
|
||||
|
||||
14
README.md
14
README.md
@@ -344,8 +344,20 @@ AliyunOSS.asyncListBuckets().then((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').then((e)=>{
|
||||
AliyunOSS.asyncListObjects('luozhang002', {
|
||||
prefix:'xxxx'
|
||||
}).then((e)=>{
|
||||
console.log(e)
|
||||
}).catch((e)=>{
|
||||
console.log(e)
|
||||
|
||||
@@ -92,12 +92,27 @@ public class AliyunObjectManager {
|
||||
/**
|
||||
* asyncListObjects
|
||||
* @param bucketName
|
||||
* @param prefix
|
||||
* @param opitons {delimiter|prefix|marker|maxkeys}
|
||||
* @param promise
|
||||
*/
|
||||
public void asyncListObjects(String bucketName,String prefix,final Promise promise) {
|
||||
public void asyncListObjects(String bucketName, ReadableMap options, final Promise promise) {
|
||||
ListObjectsRequest listObjects = new ListObjectsRequest(bucketName);
|
||||
listObjects.setPrefix(prefix);
|
||||
|
||||
if(options.hasKey("prefix")) {
|
||||
listObjects.setPrefix(options.getString("prefix"));
|
||||
}
|
||||
|
||||
if(options.hasKey("delimiter")) {
|
||||
listObjects.setDelimiter(options.getString("delimiter"));
|
||||
}
|
||||
|
||||
if(options.hasKey("marker")) {
|
||||
listObjects.setMarker(options.getString("delimiter"));
|
||||
}
|
||||
|
||||
if(options.hasKey("maxkeys")) {
|
||||
listObjects.setMaxKeys(options.getInt(String.valueOf(options.getInt("maxkeys"))));
|
||||
}
|
||||
|
||||
// set success 、set fail 、set async request
|
||||
OSSAsyncTask task = mOSS.asyncListObjects(listObjects, new OSSCompletedCallback<ListObjectsRequest, ListObjectsResult>() {
|
||||
|
||||
@@ -332,8 +332,8 @@ public class RNAliyunOssModule extends ReactContextBaseJavaModule {
|
||||
* @param promise
|
||||
*/
|
||||
@ReactMethod
|
||||
public void asyncListObjects(String bucketName,String prefix,final Promise promise) {
|
||||
mObjectManager.asyncListObjects(bucketName, prefix, promise);
|
||||
public void asyncListObjects(String bucketName,ReadableMap options,final Promise promise) {
|
||||
mObjectManager.asyncListObjects(bucketName, options, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user