[Problem/Question]
Good day!
I am sending message files to a personal open channel.
From my experience, I will say this: if I send a file of less than 1 megabyte, then everything is fine. But if I send a file larger than 1 megabyte, I get a “Request timeout” warning. At the same time, the progress of sending the file goes astray and becomes 0 percent.
// If problem, please fill out the below. If question, please delete.
[SDK Version]
com.sendbird.chat
4.0.0-beta.3
[Reproduction Steps]
-
I use the NativeGallery plugin to select a file to send and receive the string filePath response
-
I pass the received filePath as an argument to create a new SbFileInfo, something like:
var sbFileMessageCreateParams = new SbFileMessageCreateParams(new SbFileInfo(pathToBigPhoto)) { FileSize = size, };
I can specify the FileSize, or I can not transfer it, because it does not change anything
- If the file is less than 1 megabyte or it has time to go to the servers before receiving a “Request timeout” message, then the file is sent. And if not, then not
I will indicate my implementation of the method
public static void SendPhotoToMyselfChannel(SbFileMessageCreateParams fileMessageCreateParams, SbMultiProgressHandler inProgressHandler, SbFileMessageHandler inCompletionHandler )
{
SendbirdProfile.MyselfChannel.SendFileMessage(fileMessageCreateParams, inProgressHandler,inCompletionHandler);
}
Using the method:
public void TestSend()
{
var sbFileMessageCreateParams = new SbFileMessageCreateParams(new SbFileInfo(pathToBigPhoto))
{
FileSize = size
};
SbExtentions.SendPhotoToMyselfChannel(sbFileMessageCreateParams,
UploadHandler, OnCompleteHandler);
}
private void UploadHandler(string inRequestId, ulong inBytesSent, ulong inTotalBytesSent,
ulong inTotalBytesExpectedToSend)
{
var percent = inBytesSent / (float)inTotalBytesExpectedToSend;
SetLoaderCircle(percent);
}
private void OnCompleteHandler(SbFileMessage inFileMessage, SbError inError)
{
if (inError != null)
{
Debug.Log(inError.ErrorMessage);
SetEmpty();
return;
}
SetPhotoReady(bigSprite, inMessage.PlainUrl);
onPhotoChanged?.Invoke();
onSaveLocal?.Invoke(inMessage, bigSprite);
}
[Frequency]
Always
[Current impact]
My task is to create something like a social network where I use a profile photo and this profile can have several photos. I store them in a public channel assigned to the user. Something like this
private static async void TryToCreateOpenChannel()
{
var postUrl = CurrenUser.GetMetaData(POST_WALL_URL);
if (postUrl == null)
{
var postWallUrl = await CreateMyPostWall();
var dictionary = new Dictionary<string, string>();
dictionary.Add(POST_WALL_URL, postWallUrl);
CurrenUser.CreateMetaData(dictionary, (newDictionaryInfo, inError ) => { });
}
else
{
SendbirdChat.OpenChannel.GetChannel(postUrl, (inChannel, inCache, inGetChannelError) =>
{
if (inGetChannelError != null)
return; // Handle error.
inChannel.Enter((inCompleteHandler)=>
{
MyselfChannel = inChannel;
});
});
}
}
private static async Task<string> CreateMyPostWall()
{
var tsk = new TaskCompletionSource<string>();
SbOpenChannelCreateParams openChannelCreateParams = new SbOpenChannelCreateParams();
openChannelCreateParams.Name = USER_ID + "Wall";
openChannelCreateParams.CustomType = "Wall";
openChannelCreateParams.OperatorUserIds = new List<string> { USER_ID };
SendbirdChat.OpenChannel.CreateChannel(openChannelCreateParams, (inChannel, inError) =>
{
if (inError != null)
{
tsk.SetResult(null);
return;
}
tsk.SetResult(inChannel.Url);
});
return await tsk.Task;
}
If I can’t solve the problem, I’ll either compress the image somehow, or use another approach to save photos (which I don’t really want, because your implementation is convenient)
Thank you!