SDKsHarmonyOS商业版
使用 URL 创建图片消息
根据已经上传的图片资源信息创建待发送消息。
原图、大图和缩略图可以使用不同资源;只有三者确实相同时才复用信息。
import sdk, {
CreateImageMessageByURLReq,
CreateImageMessageResp,
PictureBaseInfo,
} from '@openimsdk/imsdk';
const picture: PictureBaseInfo = {
uuid: uploaded.uuid,
type: 'image/jpeg',
size: uploaded.size,
width: 1280,
height: 720,
url: uploaded.url,
};
const request: CreateImageMessageByURLReq = {
sourcePicture: picture,
bigPicture: picture,
snapshotPicture: picture,
};
const response: CreateImageMessageResp = await sdk.createImageMessageByURL(request);
const message = response.message;URL、类型、大小和尺寸必须来自实际上传结果。sourcePath、bigPath 和 snapshotPath 仅用于保留可用的本地路径,可按需省略。创建成功后仍使用 sendMessage() 发送,SDK 会识别消息中已有的远端资源信息。
这个页面有帮助吗?