aliyun-oss-react-native

ObjectManager.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 ObjectManager extends Component {
  15. render() {
  16. return(
  17. <View style={styles.item}>
  18. <Text style={styles.description}>管理文件</Text>
  19. <View style={styles.detailitem}>
  20. <View style={styles.button}>
  21. <Button style={styles.button}
  22. onPress={this.clickHandle.bind(this,"asyncHeadObject")}
  23. title="asyncHeadObject"
  24. color="#841584"
  25. />
  26. </View>
  27. <View style={styles.button}>
  28. <Button style={styles.button}
  29. onPress={this.clickHandle.bind(this,"asyncListObjects")}
  30. title="asyncListObjects"
  31. color="#841584"
  32. />
  33. </View>
  34. <View style={styles.button}>
  35. <Button style={styles.button}
  36. onPress={this.clickHandle.bind(this,"asyncCopyObject")}
  37. title="asyncCopyObject"
  38. color="#841584"
  39. />
  40. </View>
  41. <View style={styles.button}>
  42. <Button style={styles.button}
  43. onPress={this.clickHandle.bind(this,"doesObjectExist")}
  44. title="doesObjectExist"
  45. color="#841584"
  46. />
  47. </View>
  48. <View style={styles.button}>
  49. <Button style={styles.button}
  50. onPress={this.clickHandle.bind(this,"asyncDeleteObject")}
  51. title="asyncDeleteObject"
  52. color="#841584"
  53. />
  54. </View>
  55. </View>
  56. </View>
  57. )
  58. }
  59. clickHandle(e) {
  60. switch(e) {
  61. case "asyncHeadObject" : {
  62. AliyunOSS.asyncHeadObject('luozhang002','yanxing').then((e) => {
  63. console.log(e)
  64. }).catch((e)=> {
  65. console.log(e)
  66. })
  67. } break;
  68. case "asyncListObjects" : {
  69. console.log("asyncListObjects")
  70. AliyunOSS.asyncListObjects('luozhang002').then((e) => {
  71. console.log(e)
  72. }).catch((e)=>{
  73. console.log(e)
  74. })
  75. } break;
  76. case "asyncCopyObject" : {
  77. AliyunOSS.asyncCopyObject('luozhang001',"2.png","luozhang002","sbsbsb").then((e) => {
  78. console.log(e)
  79. }).catch((e)=>{
  80. console.log(e)
  81. })
  82. } break;
  83. case "doesObjectExist": {
  84. AliyunOSS.doesObjectExist('luozhang001','xx.png').then((e) => {
  85. console.log(e)
  86. }).catch((e)=>{
  87. console.log(e)
  88. })
  89. } break;
  90. case "asyncDeleteObject" : {
  91. AliyunOSS.asyncDeleteObject('luozhang001','2.png').then((e)=>{
  92. Alert.alert(e)
  93. }).catch((e)=>{
  94. console.log(e)
  95. })
  96. } break;
  97. default :break;
  98. }
  99. }
  100. }