-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2.js
37 lines (32 loc) · 1.08 KB
/
example2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { Component } from 'react';
import { View, Text, Image } from 'react-native';
import ImagePickerResizer from './App'
class example2 extends Component {
constructor(props) {
super(props);
this.state = {
image: ''
};
}
getImageData = (data) => {
//upload base64 image to server
let data = new FormData()
data.append('dir', 'vendor')
data.append('image', base64)
const upload_image = await api.post(`vendor/upload_image`, data)
const filename = upload_image.data //get return image name from server
//---------------------------//
this.setState({
image: filename
})
}
render() {
return (
<View style={{ alignSelf: 'center' }}>
<ImagePickerResizer getImageData={this.getImageData} btnText={'Gallery'} resizeWidth={100} resizeHeight={100} quality={50} />
<Image source={{ uri: this.state.image}} style={{ width: 300, height: 300 }} />
</View>
);
}
}
export default example2;