由于Flex不支持媒体消息,因此不得不采取一种变通方法来将文件内容存储在s3存储桶中,并使用指向s3的链接更新媒体消息。
我正在使用以下代码更新媒体消息
http://localhost:8051/channel/CHe1XXXXXXXXXXXXXXXXX/messages/IMdb99326ebf7dXXXXXXXXXXXX
exports.updateMessage = async function (channelSID, messageSID, body) {
const messageObj = body;
const message = twilioClient.chat.services(variables.twilioServiceSID)
.channels(channelSID)
.messages(messageSID)
.update({
messageObj
})
.then(message => {
return message;
})
return message;
};
请求正文:
{
"attributes":
{ "s3_url": "https://testingbucket.s3.us-east-2.amazonaws.com/fileupload" }
}
响应:
{"name":"test-adapter","hostname":"Abinaya","pid":14696,"level":30,"res":{"statusCode":200,"responseTime":1303,"headers":{"x-request-id":"4eb0077e-53e9-4965-9eb8-f0c314444d09","content-type":"application/json; charset=utf-8"}},"event":"response","body":{"status":"success","data":{"sid":"IMdb99326ebf7XXXXXXXXXXXXXX","attributes":"{}","to":"CHe16335c4a04643XXXXXXXXXXXXX","channelSid":"CHe16335c4a04XXXXXXXXXXXX","dateCreated":"2019-11-29T13:26:20.000Z","dateUpdated":"2019-12-02T09:31:58.000Z","lastUpdatedBy":"system","wasEdited":true,"from":"chintakindisantosh@gmail.com","body":null,"index":20,"type":"media","media":{"size":119238,"filename":"dominos.png","content_type":"image/png","sid":"MEb683c0cd51391f4bXXXXXXXXXX"}},"message":"Message updated successfully"},"msg":"request end","time":"2019-12-02T09:31:58.669Z","v":0}
即使收到200 OK媒体消息后也不会更新。
答案 0 :(得分:0)
上述问题的解决方法。
该属性应为字符串,并且我们可以在其中提供JSON。
interface ChannelListInstanceCreateOptions {
attributes?: string;
createdBy?: string;
dateCreated?: Date;
dateUpdated?: Date;
friendlyName?: string;
type?: ChannelChannelType;
uniqueName?: string;
}
因此,例如,我们可以给出以下内容。
attributes : '{"clientName":"Test"}'