Hello,
Could I get some insight on potentially what is happening here? I currently have a controller setup to take in uploaded files, I then pass those to the CreateAssetAsync method. The record is created but then when I view the asset it is empty/nothing is actually stored. It’s just a blank photograph, almost like the content from the stream wasn’t picked up.
Any idea on what could be wrong here?
[HttpPost("Upload")]
public async Task Upload(List<IFormFile> Files)
{
RequestInfo requestInfo = (RequestInfo)HttpContext.Items["RequestInfo"];
long size = Files.Sum(f => f.Length);
// full path to file in temp location
var filePath = Path.GetTempFileName();
foreach (var formFile in Files)
{
if (formFile.Length > 0)
{
using (var stream = new FileStream(filePath, FileMode.Create))
{
await this._assetService.Upload(requestInfo.Tenant, formFile.FileName, formFile.ContentType, stream);
}
}
}
}
public async Task Upload(Tenant tenant, string contentName, string mimeType, Stream stream)
{
this._clientManager = this._squidexClient.GetClient(tenant.Id);
SquidexAssetClient _assetManager = this._clientManager.GetAssetClient();
await _assetManager.CreateAssetAsync(contentName, mimeType, stream);
}