public async Task <JsonResult> Upload(IFormFile file) { Stream stream = file.OpenReadStream(); ReadResult data = default; PipeReader reader = PipeReader.Create(stream); do { data = await reader.ReadAsync(); reader.AdvanceTo(data.Buffer.Start, data.Buffer.End); }while (data.IsCompleted); ReadOnlySequence <byte> blob = data.Buffer; BlobItemDto item = new BlobItemDto { Content = blob.ToArray(), Length = file.Length, Name = file.FileName, ContentType = file.ContentType, Id = Thread.CurrentThread.ManagedThreadId, Md5 = $"{GetHashCode()}", }; await BlobService.CreateAsync(item); return(Json(item)); }
public async Task <JsonResult> Now(int id = 0) { BlobItemDto item = await BlobService.GetAsync(id); return(Json(item)); }