Пример #1
0
        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));
        }
Пример #2
0
        public async Task <JsonResult> Now(int id = 0)
        {
            BlobItemDto item = await BlobService.GetAsync(id);

            return(Json(item));
        }