I’m facing problem once I will send file, below is my code:
If I will pass wrong data the getting error but once pass correct data then not able to get success.
Sorry but are you referring to this documentation for sending file messages?
Because parameters for your message should go like:
// Let's say you have a <input type="file" id="attachFile" />
const files = document.getElementById('attachFile').files;
const file = files[0];
console.dir(file);
// Sending a file message with a raw file
const params = new sb.FileMessageParams();
params.file = file; // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
params.fileName = file.name;
params.fileSize = file.size;
params.thumbnailSizes = [{maxWidth: 100, maxHeight: 100}, {maxWidth: 200, maxHeight: 200}];
params.mimeType = file.type;
params.mentionType = 'users'; // Either 'users' or 'channel'
params.pushNotificationDeliveryOption = 'default'; // Either 'default' or 'suppress'
// CustomType, Data, etc. You can include all of them into 'params'
groupChannel.sendFileMessage(params, function(fileMessage, error) {
if (error) {
alert(error);
} else {
console.log(fileMessage);
alert('Success!');
}
});
I already a tried with the same way you suggested.
I’m passing
file = {
uri: ‘content://media/external/images/media/531’,
name: ‘IMG_1581070571244.jpg’,
type: ‘image/jpeg’
}
const files = document.getElementById('attachFile').files;
const file = files[0]; // Grab the first (this is a demo only. Need to validate not null and index)
console.dir(file)
Thanks for your quick reply.
If I will pass wrong data in file then got the error so I think I’m passing correct way for pass file and I have used below package for get image using React Native.