Skip to content

DataStore.SetSegmented() Maximum segment size is not optimal for big files > 1 MB #31

@jianmingyong

Description

@jianmingyong

I have tested uploading a 2MB worth of junk data. At first, I used the default method it offers.

using (var fileStream = new FileStream(string.Format(DirectoryService.MusicContentDirectoryFormat, DirectoryService.ContentDirectory).ResolveFullPath() + "/Some2MBMusicFile.ogg", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
    using (var memoryStream = new MemoryStream())
    {
        fileStream.CopyTo(memoryStream);
        var data = Convert.ToBase64String(memoryStream.ToArray());

        DataStore.SetSegmented("test", data, true, a => Debug.Log(a), b => Debug.Log(b));
    }
}

I edited the response error handler a little to get me a better error unity throws: (Unity really need to improve that lol) response.downloadHandler.text > Instead of response.error

It would still throw "413 (Request Entity Too Large)". However, now that I specify a smaller segment size, let say DataStore.SoftLimit / 2. It works!

The method still works for smaller data less than 1MB but it seems like the segment size isn't optimal enough to be used for bigger files without specifying a smaller default segment size.

So in summary, this soft limit could be improved further. If I can find an optimal value, I would let you know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions