Squidex.ClientManager Asset Manager

I’m submitting a…

  • [X] Bug report

Environment

  • [X] Self hosted with IIS

Version: Squidex.ClientManager Nuget 4.1.1

I am using a current version of Client Manager. In this version, the assets can be reached via CreateAssetsClient ().

Now we wanted to upload a file, but the file is shown in Squidex, but empty.

Our code:

private async Task<AssetDto> CreateFileAsync(IFormFile file)
        {
            var filePath = Path.GetTempFileName();
            if (file.Length > 0)
            {
                await using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    try
                    {
                        var fileParam = new FileParameter(stream, file.FileName, file.ContentType);
                        return await apiClientManager.CreateAssetsClient().PostAssetAsync("timeline", fileParam);
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex.Message, ex);
                    }
                }
            }

            return new AssetDto();
        }

result:
asset_upload

Am I doing anything wrong?

Greetings Andreas

FileMode.Create creates a nw file :wink:

Oh no …!
Yes, now I see it too. Too early in the morning!

await using (var stream = file.OpenReadStream ())

Works…

Thank you :wink:

1 Like