Untitled

 avatar
unknown
plain_text
3 years ago
818 B
4
Indexable
  const pickImage = async () => {
    // No permissions request is necessary for launching the image library
    const result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.All,
      allowsEditing: true,
      aspect: [4, 3],
      quality: 1,
    });

    if (!result.cancelled) {
      setImage(result.uri);
    }
  };

  const uploadSelected = async () => {
    const formData = new FormData();
    formData.append("photo", {
      // @ts-ignore
      uri: image,
      name: `photo.png`,
      type: `image/png`,
    });

    axios
      .post("http://192.168.1.102:8080/v1/test/expo-upload", formData, {
        headers: { "Content-Type": "multipart/form-data" },
      })
      .then((res) => console.log(res))
      .catch((err) => console.log(err.response));
  };
Editor is loading...