I'm trying to create a group Channel with a cover photo,
this.sendBirdInstance.GroupChannel.createChannelWithUserIds(userIds, true, this.groupName, this.groupPhotoFile, '', function (createdChannel, error) {
...
}
According to the documentation I can add a url or a file
coverUrl : the file or URL of the cover image, which you can fetch to render into the UI.
But when adding a file, I'm always getting : "SendBirdException", code: 800110, message: "Invalid arguments."
Is there a way to create a group with a file instead of a url (since I want the user to upload the file) ?
Thanks,
As you have already experienced (I saw that you have created an issue in GitHub several days ago) the support of SendBird is kinda unreliable.
The fact that they offer just a minified version of their JavaScript SDK (which personally I find very poor) is helping either.
Anyway, I could isolate the
createChannelWithUserIds
function:You are using the function like this:
So the fourth parameter (
r
) iscoverURL
: the file with the cover picture (this.groupPhotoFile
);Its validation is basically saying that:
that parameter is invalid.
Your file is not a string, not null and not undefined, so everything boils down to the
h()
function:The function above check in first place if the object has any property what is a member of the object itself (i.e. not properties belonging to the prototype chain). Then, if it doesn't have any own property, it checks if the stringify object/array is equal to an empty object/array.
I can't say what is the intention of the developers when validating files though this function, but a standard FILE object:
true
.true
.As we saw before, we need
h()
to returnfalse
: the validation fails if it returnstrue
.To fix this behavior you could change the
h()
function to something like:but I won't mess with it. It could be used in future versions with a different purpose.
So your best bet is to change the
createChannelWithUserIds()
function to:h()
function from the validation.To do that, you could override the function in a SendBird instance:
But it is not guarantee to work and could break in future releases, so I would just edit the SendBird.min.js file. In other words, replace:
with:
In the current version (v3.0.41) you will find two coincidences of the code above: one for
createChannel
and other forcreateChannelWithUserIds
, you can replace both.Of course, editing the .js file is annoying because you will need to take care to replace the code everytime you upgrade SendGrid. You could create an automatic task inside your CI pipeline to do it for you, thought.
Hopefully, the SendGrid developers will acknowledge your issue and fix it in a future release.