aliyun-oss-react-native

ObjectManager.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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',{
  71. prefix:'xxxx'
  72. }).then((e) => {
  73. console.log(e)
  74. }).catch((e)=>{
  75. console.log(e)
  76. })
  77. } break;
  78. case "asyncCopyObject" : {
  79. AliyunOSS.asyncCopyObject('luozhang001',"2.png","luozhang002","sbsbsb").then((e) => {
  80. console.log(e)
  81. }).catch((e)=>{
  82. console.log(e)
  83. })
  84. } break;
  85. case "doesObjectExist": {
  86. AliyunOSS.doesObjectExist('luozhang001','xx.png').then((e) => {
  87. console.log(e)
  88. }).catch((e)=>{
  89. console.log(e)
  90. })
  91. } break;
  92. case "asyncDeleteObject" : {
  93. AliyunOSS.asyncDeleteObject('luozhang001','2.png').then((e)=>{
  94. Alert.alert(e)
  95. }).catch((e)=>{
  96. console.log(e)
  97. })
  98. } break;
  99. default :break;
  100. }
  101. }
  102. }