Advertisement
marceloboy1

Uploader

Feb 21st, 2021
1,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   async function videoPicker() {
  2.  
  3.     const file = await ImagePicker.launchImageLibraryAsync({
  4.       mediaTypes: ImagePicker.MediaTypeOptions.Video,
  5.     });
  6.     setVideo(file);
  7.   }
  8.  
  9.   async function uploadVideo(){
  10.  
  11.     var movVideo = {
  12.       uri: video.uri,
  13.       type: 'video/mp4',
  14.       name: (title)+'.mp4'
  15.     }
  16.  
  17.     var body = new FormData();
  18.     body.append('file', movVideo);
  19.     body.append('title', title);
  20.  
  21.     fetch('http://192.168.0.106:3333/upload', {
  22.       method: "POST",
  23.       headers: {
  24.         'Accept': 'application/json',
  25.         'Content-Type': 'multipart/form-data',
  26.         'authorization': 'c99afe28'
  27.       },
  28.       body: body,
  29.     }).then((response) => {
  30.       setPicked(false)
  31.       response.json()
  32.     })
  33.       .then((responseJson) => {
  34.         Alert.alert("UPLOAD COMPLETO");
  35.         console.log(responseJson);
  36.     });
  37.   }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement