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

[BUG] createImageMessageFromFullPath return empty #34

Closed
neilzhengzx opened this issue May 31, 2024 · 31 comments
Closed

[BUG] createImageMessageFromFullPath return empty #34

neilzhengzx opened this issue May 31, 2024 · 31 comments

Comments

@neilzhengzx
Copy link

neilzhengzx commented May 31, 2024

OpenIM Server Version

open-im-sdk-rn 3.5.1-rc.2

Operating System and CPU Architecture

macOS (ARM)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

new demo release
String message = Open_im_sdk.createImageMessageFromFullPath(operationID, imagePath);
message get ""

Screenshots Link

No response

@oudi
Copy link

oudi commented Jun 4, 2024

image

Open_im_sdk.createImageMessageFromFullPath(operationID, imagePath) return empty cause JSON parse error.

pc web works well, only error in RN version.

@lgz5689
Copy link
Member

lgz5689 commented Jun 4, 2024

What parameters did you pass in

@lgz5689 lgz5689 changed the title [BUG] [BUG] createImageMessageFromFullPath return empty Jun 4, 2024
@neilzhengzx
Copy link
Author

in this project -> Footer.tsx -> selectImage ,
const message = await OpenIMSDKRN.createImageMessageFromFullPath(originalPath, "qwertyuiop");

@lgz5689
Copy link
Member

lgz5689 commented Jun 4, 2024

It works fine on the emulator

{"clientMsgID": "abab7f7b32e5b0ab8558fd3e58b04afd", "contentType": 102, "createTime": 1717468074338, "isRead": false, "msgFrom": 100, "pictureElem": {"sourcePath": "/sdcard/.transforms/synthetic/picker/0/com.android.providers.media.photopicker/media/1000000019.jpg", "sourcePicture": {"height": 1920, "size": 0, "type": "image/jpeg", "width": 1440}}, "sendID": "7733257624", "sendTime": 1717468074338, "senderNickname": "17500000001", "senderPlatformID": 2, "seq": 0, "sessionType": 0, "status": 1}

Verify the originalPath content when using the real machine

@neilzhengzx
Copy link
Author

测试是权限未申请,修改后可以收到回调. 但图片稍大一点,app会崩溃:

try {
      const granted = await PermissionsAndroid.requestMultiple([
        PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
        PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      ]);
      if (
        granted[PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE] === PermissionsAndroid.RESULTS.GRANTED &&
        granted[PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE] === PermissionsAndroid.RESULTS.GRANTED
      ) {
        const response = await launchImageLibrary({
          mediaType: "photo",
          selectionLimit: 1,
        });
        if (response.didCancel || response.errorCode) return;
        if (response.assets && response.assets.length > 0) {
          let { originalPath } = response.assets[0];
          if (originalPath) {
            const message = await OpenIMSDKRN.createImageMessageFromFullPath(originalPath, "qwertyuiop");
            console.log("return message:" + message);
            sendMessage({ message });
          }
        }
      } else {
        console.log("not allow permission");
      }
    } catch (err) {
      console.log("cancel");
    }

@lgz5689
Copy link
Member

lgz5689 commented Jun 4, 2024

About how many MB?try to use Android Studio collect logs

@neilzhengzx
Copy link
Author

neilzhengzx commented Jun 11, 2024

image size 277kb:
options:
{
"recvID": "6491348764",
"groupID": "",
"message":
{
"seq": 0,
"contentType": 102,
"clientMsgID": "0b486acaec2fd29270ddf5c210565df9",
"senderFaceUrl": "https://*/api/object/6374389285/image_cropper_1717056293429.jpg",
"sendTime": 1718095579317,
"sendID": "6374389285",
"senderPlatformID": 2,
"isRead": false,
"pictureElem":
{
"sourcePath": "/storage/emulated/0/Pictures/Screenshots/Screenshot_20240110_164848.jpg",
"sourcePicture":
{
"height": 1600,
"type": "image/jpeg",
"width": 720,
"size": 0
}
},
"status": 1,
"msgFrom": 100,
"sessionType": 0,
"createTime": 1718095579317,
"senderNickname": "openimtest"
}
}

api:
const successMessage = await OpenIMSDKRN.sendMessage(options, "opid");

err:
{
"nativeStackAndroid":
[],
"userInfo": null,
"message": "500 invalid multipart upload id: unexpected end of JSON input invalid multipart upload id: unexpected end of JSON input",
"code": "500"
}

@c2pc
Copy link

c2pc commented Jul 1, 2024

I have the same error!

error [Error: 500 ServerInternalError invalid multipart upload id: unexpected end of JSON input]

Have you fixed the error?

@lgz5689
Copy link
Member

lgz5689 commented Jul 1, 2024

@c2pc
Copy link

c2pc commented Aug 5, 2024

when is the release with this fix?

@lgz5689
Copy link
Member

lgz5689 commented Aug 7, 2024

The SDK will be updated this week

@lgz5689
Copy link
Member

lgz5689 commented Aug 9, 2024

Code and sdk updated to the latest 3.8.1-rc.0

@neilzhengzx
Copy link
Author

此项目更新后,在后端未更新的情况下,图片上传仍然崩溃, 此问题未修复 @lgz5689

@lgz5689
Copy link
Member

lgz5689 commented Aug 13, 2024

Make sure that both the server and client are 3.8

@c2pc
Copy link

c2pc commented Aug 14, 2024

"open-im-sdk-rn": "3.8.1-rc.0"

The code OpenIMSDKRN.createFileMessageFromFullPath({ filePath:uri, fileName: name }, Date.now().toString()) returns an error Value for message cannot be cast from String to ReadableNativeMap

but if I send String
the code OpenIMSDKRN.createFileMessageFromFullPath(uri, Date.now().toString()) also returns an error String cannot be cast to ReadableNativeMap

In OpenImSdkRnModule.java I see public void createFileMessageFromFullPath(ReadableMap options, String operationID, Promise promise) but in JS file createFileMessageFromFullPath: ( params: string, operationID: string ) => Promise<MessageItem>; params is string

@lgz5689
Copy link
Member

lgz5689 commented Aug 14, 2024

This problem is most likely caused by differences in the values returned by the map.toString function in different versions, and this compatibility issue will be fix in the near future

@lgz5689
Copy link
Member

lgz5689 commented Aug 14, 2024

"open-im-sdk-rn": "3.8.1-rc.0"

The code OpenIMSDKRN.createFileMessageFromFullPath({ filePath:uri, fileName: name }, Date.now().toString()) returns an error Value for message cannot be cast from String to ReadableNativeMap

but if I send String the code OpenIMSDKRN.createFileMessageFromFullPath(uri, Date.now().toString()) also returns an error String cannot be cast to ReadableNativeMap

In OpenImSdkRnModule.java I see public void createFileMessageFromFullPath(ReadableMap options, String operationID, Promise promise) but in JS file createFileMessageFromFullPath: ( params: string, operationID: string ) => Promise<MessageItem>; params is string

What is your version of react-native

@lgz5689 lgz5689 transferred this issue from openimsdk/openim-reactnative-demo Aug 14, 2024
@lgz5689
Copy link
Member

lgz5689 commented Aug 14, 2024

see #32

@c2pc
Copy link

c2pc commented Aug 15, 2024

"open-im-sdk-rn": "3.8.1-rc.0"
Код OpenIMSDKRN.createFileMessageFromFullPath({ filePath:uri, fileName: name }, Date.now().toString())возвращает ошибку Значение для сообщения не может быть преобразовано из String в ReadableNativeMap
но если я отправляю String, код OpenIMSDKRN.createFileMessageFromFullPath(uri, Date.now().toString())также возвращает ошибку String не может быть приведен к ReadableNativeMap
В OpenImSdkRnModule.java я вижу, public void createFileMessageFromFullPath(ReadableMap options, String operationID, Promise promise)но в файле JS createFileMessageFromFullPath: ( params: string, operationID: string ) => Promise<MessageItem>;параметры — это строка

Какова ваша версия?react-native

0.72.6

@c2pc
Copy link

c2pc commented Aug 16, 2024

see #32

I updated the version to the latest, corrected the java file, but my error is the same
Value for message cannot be cast from String to ReadableNativeMap in OpenIMSDKRN.createFileMessageFromFullPath({ filePath:uri, fileName: name }, Date.now().toString())

but it works in iOS

react-native: 0.72.6
open-im-sdk-reactnative: 3.8.1-rc.1

@lgz5689
Copy link
Member

lgz5689 commented Aug 16, 2024

see #32

I updated the version to the latest, corrected the java file, but my error is the same Value for message cannot be cast from String to ReadableNativeMap in OpenIMSDKRN.createFileMessageFromFullPath({ filePath:uri, fileName: name }, Date.now().toString())

but it works in iOS

react-native: 0.72.6 open-im-sdk-reactnative: 3.8.1-rc.1

Please read this article carefully. Obviously you didn't read it in its entirety

@daxingyun
Copy link

您好,创建文件和视频消息时,返回空值,创建图片消息正常。
截图如下:
微信图片_20240927155151
微信图片_20240927155243

请注意看打印的日志,我有输出filePath的值 以及返回的message。
日志可以看出message是返回空值。

异常信息为:[open_im_sdk/caller.go:260] fn call error

除此之外没有任何别的有用信息。

@lgz5689
Copy link
Member

lgz5689 commented Oct 31, 2024

您好,创建文件和视频消息时,返回空值,创建图片消息正常。 截图如下: 微信图片_20240927155151 微信图片_20240927155243

请注意看打印的日志,我有输出filePath的值 以及返回的message。 日志可以看出message是返回空值。

异常信息为:[open_im_sdk/caller.go:260] fn call error

除此之外没有任何别的有用信息。

Collect more logs in the console, only one fn call error can not troubleshoot the problem, you need to provide more logs to find the problem

@Rater93
Copy link

Rater93 commented Oct 31, 2024

聊天传图片的场景,我用createImageMessageFromFullPath
运行环境:ios模拟器,react native版本3.8.1,服务端版本release-v3.8.1

console.info('messageItem::', mediaPath, operationID)
messageItem = await OpenIMSDKRN.createImageMessageFromFullPath(mediaPath, operationID);
console.info('messageItem::', messageItem)

结果messageItem 返回空,

632f08fe8875fa9172e4cbd112d1b02

@lgz5689
Copy link
Member

lgz5689 commented Oct 31, 2024

Try to remove file://, and confirm that the app permission has been applied, if it has not been properly executed, please provide more sdk-core log content

@Rater93
Copy link

Rater93 commented Oct 31, 2024

Try to remove file://, and confirm that the app permission has been applied, if it has not been properly executed, please provide more sdk-core log content尝试去掉file:// ,并确认app权限已经申请,如果没有正确执行,请提供更多sdk-core日志内容

去掉file后,还是有问题
messageItem:: {"clientMsgID": "6701b6586d52cdcc96dfbdebd25abb19", "contentType": 102, "createTime": 1730382771646, "isRead": false, "msgFrom": 100, "pictureElem": {"sourcePath": "/Users/vikiy/Library/Developer/CoreSimulator/Devices/A2AFC8A2-9B87-4F6E-8FE6-13C3C47DA414/data/Containers/Data/Application/2C31320F-CF27-4C0B-85BE-35DA2C85C1C2/tmp/8AA2A516-BF3C-4A21-A345-4EC29677833E.jpg", "sourcePicture": {"height": 2500, "size": 0, "type": "image/jpeg", "width": 1668}}, "sendID": "6610e5056afc8c5cb2fb970c", "sendTime": 1730382771646, "senderFaceUrl": "https://joyn-user-avatar.s3.us-west-2.amazonaws.com/file.d07f847e0550431da3f8e2a48fead2b8_avatar.jpg", "senderNickname": "AmyJohnsson", "senderPlatformID": 1, "seq": 0, "sessionType": 0, "status": 1}

sourcePicture并没有url等信息,size也是为0,height,width倒是有

@lgz5689
Copy link
Member

lgz5689 commented Nov 1, 2024

This is normal, and when the message is successfully sent, the callback returns a message body containing all the contents

@Rater93
Copy link

Rater93 commented Nov 1, 2024

This is normal, and when the message is successfully sent, the callback returns a message body containing all the contents这是正常的,当消息发送成功后,回调会返回包含所有内容的消息体

这是对方接收到的消息内容
{"attachedInfoElem": {"burnDuration": 0, "groupHasReadInfo": {"groupMemberCount": 0, "hasReadCount": 0}, "hasReadTime": 0, "inEncryptStatus": false, "isEncryption
": false, "isPrivateChat": false}, "clientMsgID": "6701b6586d52cdcc96dfbdebd25abb19", "contentType": 102, "createTime": 1730382771646, "isRead": false, "msgFrom": 100, "pictureElem
": {"sourcePath": "/Users/vikiy/Library/Developer/CoreSimulator/Devices/A2AFC8A2-9B87-4F6E-8FE6-13C3C47DA414/data/Containers/Data/Application/2C31320F-CF27-4C0B-85BE-35DA2C85C1C2/t
mp/8AA2A516-BF3C-4A21-A345-4EC29677833E.jpg", "sourcePicture": {"height": 2500, "size": 0, "type": "image/jpeg", "width": 1668}}, "recvID": "662065d9002cdc3815f6ec4c", "sendID": "6
610e5056afc8c5cb2fb970c", "sendTime": 1730382772412, "senderFaceUrl": "https://joyn-user-avatar.s3.us-west-2.amazonaws.com/file.d07f847e0550431da3f8e2a48fead2b8_avatar.jpg", "senderNickname": "AmyJohnsson", "senderPlatformID": 1, "seq": 24, "serverMsgID": "a78595e1f5928b7513bad095b4eaf950", "sessionType": 1, "status": 2}

消息内容图片相关的信息只有IOS虚拟机的路径,对于消息接收方来说,这个路径有什么意义么,没有其他可用的可用于展示这个图片的消息内容吗

@lgz5689
Copy link
Member

lgz5689 commented Nov 1, 2024

After the message has been successfully sent, you can get the complete structure of the message. The sourcePath doesn't make sense to the message receiver.

@Rater93
Copy link

Rater93 commented Nov 1, 2024

After the message has been successfully sent, you can get the complete structure of the message. The sourcePath doesn't make sense to the message receiver.

这是消息接收方所接收到的消息,里面并没有可以展示这张图片的信息
{"attachedInfoElem": {"burnDuration": 0, "groupHasReadInfo": {"groupMemberCount": 0, "hasReadCount": 0}, "hasReadTime": 0, "inEncryptStatus": false, "isEncryption
": false, "isPrivateChat": false}, "clientMsgID": "625991a366fafe332170c45b0c0bf218", "contentType": 102, "createTime": 1730358688663, "isRead": false, "msgFrom": 100, "pictureElem
": {"sourcePath": "/Users/vikiy/Library/Developer/CoreSimulator/Devices/A2AFC8A2-9B87-4F6E-8FE6-13C3C47DA414/data/Containers/Data/Application/2C31320F-CF27-4C0B-85BE-35DA2C85C1C2/t
mp/E07D07D3-9FD3-4C75-9B90-CBCD0C2BAD84.jpg", "sourcePicture": {"height": 2002, "size": 0, "type": "image/jpeg", "width": 3000}}, "recvID": "662065d9002cdc3815f6ec4c", "sendID": "6
610e5056afc8c5cb2fb970c", "sendTime": 1730358689044, "senderFaceUrl": "https://joyn-user-avatar.s3.us-west-2.amazonaws.com/file.d07f847e0550431da3f8e2a48fead2b8_avatar.jpg", "senderNickname": "AmyJohnsson", "senderPlatformID": 1, "seq": 23, "serverMsgID": "304053530b716a290b21d9ebb30387f3", "sessionType": 1, "status": 2}

@lgz5689
Copy link
Member

lgz5689 commented Nov 1, 2024

Check the console sendMessage for errors, then collect local sdk-core logs.

@lgz5689 lgz5689 closed this as completed Nov 29, 2024
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

6 participants