如何在React Expo中将图像发送到服务器

问题描述 投票:0回答:1

我通过这种方式通过android studio中的位图将图像发送到服务器:

  bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), resultUri);

       ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap = Bitmap.createScaledBitmap(bitmap , 500, 500, true);
        bitmap .compress(Bitmap.CompressFormat.JPEG, 100, baos);

        byte[] imageBytes = baos.toByteArray();
        String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);


现在在博览会中,我使用图像选择器获得了uri],如何在react expo中做到这一点?

我通过这种方式通过android studio中的位图将图像发送到服务器:bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),resultUri); ByteArrayOutputStream baos = new ...

react-native bitmap expo imagepicker
1个回答
0
投票

如果这样使用RestAPI,可以在后端发送formData

© www.soinside.com 2019 - 2024. All rights reserved.