How to programatically send large IFC files to speckle using .NET SDK?

Hello, I am experimenting with the .NET SDK, and I would like to send large IFC files (321MB) to Speckle. How can I achieve this?

When I send smaller IFC files, it works correctly, but when I want to send larger data, I get the following error: An existing connection was forcibly closed by the remote host.

        string endpoint = "https://app.speckle.systems/api/file/autodetect/bbe2e198ff/test";
        string filepath = "D:/Speckle/IFC/KNR-K-E-XX-3D-XXX-100-KNORR BREMSE CENTRAL (33).ifc";
        string token = "91fe7fe8e47aeb4daef95a7ab01df07662e964d31a";//"ac7f250a838152dd69b538f08f6eef8cf125af7fa8";

        using (var httpClient = new HttpClient())
        {
            using (var formData = new MultipartFormDataContent())
            {
                using (var fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read))
                {
                    formData.Add(new StreamContent(fileStream), "file", Path.GetFileName(filepath));

                    httpClient.DefaultRequestHeaders.Add("Authorization", token);
                    httpClient.Timeout = new TimeSpan(1, 15, 0);

                    var response = await httpClient.PostAsync(endpoint, formData);

                    if (response.IsSuccessStatusCode)
                    {
                        var content = await response.Content.ReadAsStringAsync();
                        _logger.LogInformation(content);
                        return Ok(content);
                    }
                    else
                    {
                        var errorResponse = await response.Content.ReadAsStringAsync();
                        _logger.LogInformation(errorResponse);
                        return BadRequest(errorResponse);
                    }
                }
            }
        }

Hi @Botond_Biro, can you let us know which server you are using? There are some hard coded limits we impose, but those are flexible and can be changed based on your needs - I don’t remember what the defaults are right now (maybe @iainsproat or @gjedlicska do!)

By default a Speckle Server deployment will limit file sizes to 100Mb or less.

Iain

Thanks for the quick response. So, on the published server that I’m just using (app.speckle.systems), I cannot change the file upload limit? In the end, my goal is to be able to upload large files to my own local development environment.

The limit is set for the entire server and can only be configured by the server operator; https://app.speckle.systems currently has a 100Mb limit.
If you are running your own development server locally, it can be amended by changing the FILE_SIZE_LIMIT_MB environment variable on the speckle-server service defined in the docker compose file.

Iain

I understand, thank you for the help. :grinning: