Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. handleChoosePhoto = () => {
  2. var options = {
  3. title: 'Select Image',
  4. storageOptions: {
  5. skipBackup: true,
  6. path: 'images',
  7. },
  8. };
  9. ImagePicker.showImagePicker(options, response => {
  10. if (response.uri) {
  11. console.log(response)
  12. this.setState({ photo: response })
  13. }
  14. //alert(this.state.photo.fileName)
  15. //this.onSubmitPhoto();
  16. })
  17. }
  18.  
  19. onSubmitPhoto = (e) => {
  20.  
  21. var url = 'https://absensiapiendpoint.azurewebsites.net/api/BlobStorage/InsertFile';
  22. const Header = {
  23. // 'Content-Type': 'multipart/form-data',
  24. // 'accept' : 'text/plain'
  25. }
  26.  
  27. var formData = new FormData();
  28. formData.append("stream", this.state.photo, this.state.photo.fileName)
  29. axios.post(url, formData ,Header)
  30. .then(data => {
  31. this.setState({
  32. urlphoto : data.data
  33. })
  34. alert(this.state.urlphoto)
  35. console.log("ulrnya : " + this.state.urlphoto)
  36. }).catch(err => {
  37. //alert(err)
  38. console.log(err)
  39. }
  40. )
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement