Asset upload size config - Docker

You’re right, this is the real error. So this is a bug?

Can you also open the details? It is a bug, but only that the exception message is too specific.

I think exception.ToString() should also show a lot.

Furthermore you can enable ReadResponseAsString via the response to get the response string in the exception, but this will hurt performance.

I think exception.ToString() should also show a lot.

Validation error: Request body has an invalid format.
HTTP Response: 



Squidex.ClientLibrary.Management.SquidexManagementException`1[Squidex.ClientLibrary.Management.ErrorDto]: Asset exceeds the maximum size.

Status: 400
Response: 

   at Squidex.ClientLibrary.Management.AssetsClient.<PostAssetAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at xxxx.Common.AsyncHelper.RunSync[TResult](Func`1 func) in C:\Projects\xxxx\xxxx.Common\AsyncHelper.cs:line 17
   at xxxx.Models.Logic.SquidexCmsLogic.CreateAndUploadAsset(Stream content, Nullable`1 parentId) in C:\Projects\xxxx\xxxx.Models\Logic\Impl\SquidexCmsLogic.cs:line 142
   at xxxx.Models.Logic.SquidexCmsLogic.CreateAndUploadPartnerAsset(Stream content) in C:\Projects\xxxx\xxxx.Models\Logic\Impl\SquidexCmsLogic.cs:line 147
   at SolverAndScoreAppointmentPlanningTester.Program.Main(String[] args) in C:\Projects\xxxx\SolverAndScoreAppointmentPlanningTester\Program.cs:line 295

Please use version 5.4.

5.5. has a bug, I can reproduce it.

With 5.4 its another one:

System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<Squidex.ClientLibrary.Management.AssetDto> Squidex.ClientLibrary.Management.IAssetsClient.PostAssetAsync(System.String, System.IO.Stream, System.Nullable`1<System.Guid>, System.Threading.CancellationToken)'.
   at xxxx.Models.Logic.SquidexCmsLogic.<>c__DisplayClass27_0.<CreateAndUploadAsset>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at xxxx.Common.AsyncHelper.RunSync[TResult](Func`1 func) in C:\Projects\xxxx\xxxx.Common\AsyncHelper.cs:line 17
   at xxxx.Models.Logic.SquidexCmsLogic.CreateAndUploadAsset(Stream content, Nullable`1 parentId) in C:\Projects\xxxx\xxxx.Models\Logic\Impl\SquidexCmsLogic.cs:line 142
   at xxxx.Models.Logic.SquidexCmsLogic.CreateAndUploadPartnerAsset(Stream content) in C:\Projects\xxxx\xxxx.Models\Logic\Impl\SquidexCmsLogic.cs:line 147
   at SolverAndScoreAppointmentPlanningTester.Program.Main(String[] args) in C:\Projects\xxxx\SolverAndScoreAppointmentPlanningTester\Program.cs:line 295

But this can be solved with recompiling I think.

The problem was that there was a bug in third-party code generator. In 5.4 and before the PostAsync method was accepting a FileParameter class which takes a stream, file name and mime type as input.

With 5.6 the code generator was generating a Stream as an input argument for this method. Furthermore it was doing a normal post request and not a multipart file upload request.

So your code should look like this:

using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using System.IO;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var clientManager = new SquidexClientManager(new SquidexOptions
            {
                AppName = "integration-tests",
                ClientId = "root",
                ClientSecret = "xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0=",
                Url = "https://localhost:5001"
            });

            var assets = clientManager.CreateAssetsClient();

            var stream = new MemoryStream(new byte[] { 1, 2, 3, 4 });

            await assets.PostAssetAsync("integration-tests", new FileParameter(stream, "foo.txt", "text/plain"));
        }
    }
}

Please note that file name and mime type MUST be defined.