aliyun-oss-react-native

BucketManager.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React, { Component } from 'react';
  2. import {
  3. Platform,
  4. StyleSheet,
  5. Text,
  6. View,
  7. Alert,
  8. Button,
  9. ScrollView,
  10. Image
  11. } from 'react-native';
  12. //导入样式
  13. import { styles } from '../CSS/global.js'
  14. export class BucketManager extends Component {
  15. render() {
  16. return (
  17. <View style={styles.item}>
  18. <Text style={styles.description}>管理Bucket</Text>
  19. <View style={styles.detailitem}>
  20. <View style={styles.button}>
  21. <Button style={styles.button}
  22. onPress={this.handClick.bind(this,"asyncCreateBucket")}
  23. title="创建bucket"
  24. color="#841584"/>
  25. </View>
  26. <View style={styles.button}>
  27. <Button style={styles.button}
  28. onPress={this.handClick.bind(this,"getBucketACL")}
  29. title="获取Bucket ACL "
  30. color="#841584"
  31. />
  32. </View>
  33. <View style={styles.button}>
  34. <Button style={styles.button}
  35. onPress={this.handClick.bind(this,"getAllBuckets")}
  36. title="获取所有bucket"
  37. color="#841584"
  38. />
  39. </View>
  40. <View style={styles.button}>
  41. <Button style={styles.button}
  42. onPress={this.handClick.bind(this,"deleteBucket")}
  43. title="删除bucket"
  44. color="#841584"
  45. />
  46. </View>
  47. </View>
  48. </View>
  49. )
  50. }
  51. handClick(e) {
  52. switch(e){
  53. case 'asyncCreateBucket': {
  54. AliyunOSS.asyncCreateBucket('tyluoluo','private','oss-cn-zhangjiakou').then((e)=>{
  55. console.log(e)
  56. }).catch((e)=>{
  57. console.log(e)
  58. })
  59. } break;
  60. case "getBucketACL": {
  61. AliyunOSS.asyncGetBucketACL('luozhang002').then((e)=>{
  62. console.log(e)
  63. }).catch((e)=>{
  64. console.log(e)
  65. })
  66. } break;
  67. case "getAllBuckets": {
  68. AliyunOSS.asyncListBuckets().then((e) => {
  69. console.log(e)
  70. }).catch((e)=>{
  71. console.log(e)
  72. })
  73. } break;
  74. case 'deleteBucket': {
  75. AliyunOSS.asyncDeleteBucket("tyluoluo").then((e)=>{
  76. console.log(e)
  77. }).catch((e)=>{
  78. console.log(e)
  79. })
  80. } break;
  81. default:break;
  82. }
  83. }
  84. }