Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
android/build/
android/aliyun-oss-react-native.iml
node_modules/
.idea
.DS_Store
Example/ios/Pods/
package-lock.json
56 changes: 56 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# IntelliJ project files
.idea
*.iml
out
gen

Example/
.gitignore

.vscode

# typings
#
typings
typings.json
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
#
*.iml
.idea
.gradle
local.properties

# node.js
#
node_modules/
npm-debug.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
3 changes: 3 additions & 0 deletions Example/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
6 changes: 6 additions & 0 deletions Example/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
54 changes: 54 additions & 0 deletions Example/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*

; Ignore metro
.*/node_modules/metro/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/

[options]
emoji=true

module.system=haste

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[version]
^0.67.0
1 change: 1 addition & 0 deletions Example/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
56 changes: 56 additions & 0 deletions Example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle
1 change: 1 addition & 0 deletions Example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
60 changes: 60 additions & 0 deletions Example/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { Component } from 'react';

import {
StyleSheet,
View,
ScrollView,
} from 'react-native';

import { AuthManager } from './Component/AuthManager'
import { UploadManager } from './Component/UploadManager'
import { DownloadManager } from './Component/DownloadManager'
import { ImageProcessManager } from './Component/ImageProcessManager'
import { BucketManager } from './Component/BucketManager'
import { ObjectManager } from './Component/ObjectManager'

import AliyunOSS from 'aliyun-oss-react-native'
//open log
AliyunOSS.enableDevMode()
// defalut configraiton
const configuration = {
maxRetryCount: 3,
timeoutIntervalForRequest: 30,
timeoutIntervalForResource: 24 * 60 * 60
};
const config = {
AccessKey: 'XXX',
SecretKey: 'XXX',
};
const endPoint = 'oss-cn-zhangjiakou.aliyuncs.com';
const companyserver = "http://XXX:PORT";
const familyserver = "http://XXX:PORT";

// AliyunOSS.initWithPlainTextAccessKey(config.AccessKey, config.SecretKey, endPoint, configuration);
AliyunOSS.initWithServerSTS(familyserver,endPoint, configuration)

type Props = {};

export default class App extends Component<Props> {
render() {
return (
<ScrollView>
<View style={styles.container}>
<AuthManager/>
<UploadManager/>
<DownloadManager/>
<ImageProcessManager/>
<BucketManager/>
<ObjectManager/>
</View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
flexDirection:'column',
backgroundColor: '#F5FCFF',
flexWrap:'wrap'
}
});
28 changes: 28 additions & 0 deletions Example/CSS/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import { StyleSheet } from 'react-native'

export const styles = StyleSheet.create({
container: {
flexDirection:'column',
backgroundColor: '#F5FCFF',
flexWrap:'wrap'
},
description: {
fontSize:20,
marginTop:10,
marginLeft:10,
marginBottom:20
},
item: {
justifyContent:'space-around',
marginBottom:10
},
button:{
margin:10
},
detailitem: {
flexDirection:'row',
justifyContent:'flex-start',
flexWrap:'wrap'
}
});
112 changes: 112 additions & 0 deletions Example/Component/AuthManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Alert,
Button,
ScrollView,
Image
} from 'react-native';


const configuration = {
maxRetryCount: 3,
timeoutIntervalForRequest: 30,
timeoutIntervalForResource: 24 * 60 * 60
};

const config = {
AccessKey: 'XXX',
SecretKey: 'XXX',
};

const STSConfig = {
AccessKeyId:'XXX',
SecretKeyId:'XXX',
SecurityToken:'XXX'
}

const endPoint = 'oss-cn-zhangjiakou.aliyuncs.com';
const companyserver = "http://XXX:PORT"
const familyserver = "http://XXX:PORT"

//导入样式
import { styles } from '../CSS/global.js'

export class AuthManager extends Component {

render() {
return (
<View style={styles.item}>
<Text style={styles.description}>Client初始化</Text>
<View style={styles.detailitem}>

<View style={styles.button}>
<Button
onPress={this.handClick.bind(this,"AKSK")}
title="AKSK明文"
color="#841584"
/>
</View>

<View style={styles.button}>
<Button style={styles.button}
onPress={this.handClick.bind(this,"Singer")}
title="自签"
color="#841584"
/>
</View>

<View style={styles.button}>
<Button style={styles.button}
onPress={this.handClick.bind(this,"STS")}
title="STS"
color="#841584"
/>
</View>

<View style={styles.button}>
<Button style={styles.button}
onPress={this.handClick.bind(this,"ServerSTS")}
title="Server STS"
color="#841584"
/>
</View>
</View>
</View>
)
}

handClick(e) {
switch(e) {

case 'AKSK' : {
Alert.alert(Platform.OS);
if (Platform.OS == 'ios') {
AliyunOSS.initWithPlainTextAccessKey(config.AccessKey,config.SecretKey,endPoint,configuration);
Alert.alert("initAKSK success!")
} else {
Alert.alert('android do not support AK SK ,please use initWithSTS')
}
} break;

case 'Singer' : {
Alert.alert('initAKSK')
} break;

case "STS": {
AliyunOSS.initWithSecurityToken(STSConfig.SecurityToken,STSConfig.AccessKeyId,STSConfig.SecretKeyId,endPoint,configuration)
Alert.alert('STS success!')
} break;

case "ServerSTS" : {
AliyunOSS.initWithServerSTS(familyserver,endPoint, configuration)
Alert.alert('initServerSTS Success!')
} break;

default: break;
}
}
}
Loading