Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload image from mobile storage with react-native-image-crop-picker doesn't work. #1961

Closed
Nibycz opened this issue Sep 30, 2021 · 0 comments

Comments

@Nibycz
Copy link

Nibycz commented Sep 30, 2021

Describe the bug
this isnt a bug but i need a little help.
i hope someone can help me. Thanks for that.

Im trying to pick an Image from my Phone with an ImagePicker.
i got following code as an example:

 const sendAttachment = () => {
    let contentUri;
    ImagePicker.openPicker(cropImagePickerOptions).then(async imageData => {
      if (!aClient.isRoomEncrypted(currentRoom.roomId)) {
        try {
          console.log({ imageData });
          await aClient
            .uploadContent(imageData, {
              rawResponse: false,
              type: imageData.mime,
              onlyContentUri: false,
            })
            .then(res => {
              contentUri = res.content_uri;
              console.log({ contentUri });
              aClient.sendImageMessage(currentRoom.roomId, contentUri);
            });
        } catch (error) {
          console.log({ error });
        }
      }
    });
  };

when i send the image i got the notificaiton that i send the image but it doesnt work. (empty image)

if i check the source of the image i got something like this:

{
  "type": "m.room.message",
  "sender": "@ee4:matrix......",
  "content": {
    "msgtype": "m.image",
    "url": "mxc://matrix......../MUAnrLHXPwGRKxIkRJuczGev",
    "body": "Image"
  },
  "origin_server_ts": 1633006157324,
  "unsigned": {
    "age": 119
  },
  "event_id": "$9lN4Op287slh2f3TKCDDMcy2rH6nbMvs5THdYNds67E",
  "room_id": "!hjqNjarseycxsAXeEp:matrix......"
}

any ideas how i can do it correctly with the react-native-image-crop-picker?

To Reproduce
Steps to reproduce the behavior:
unfortunately i cant share my whole project / code.

Screenshots
If applicable, add screenshots to help explain your problem.
grafik

Smartphone (please complete the following information):

  • Device: Nexus 5 Emulator
  • OS: Android 12

Additional context
i hope that someone maybe implemented this in react-native and can help me :)

if you need more Information just hit me up

@Nibycz Nibycz changed the title Upload image with react-native-image-crop-picker doesn't work. Upload image from mobile storage with react-native-image-crop-picker doesn't work. Sep 30, 2021
@Nibycz Nibycz closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant