Exemple #1
0
        public async Task <ActionResult <UploadStartResponse> > BatchUploadAsync(
            [FromForm] UploadRequestForm model,
            CancellationToken token)
        {
            var tempDataProvider = _tempDataDictionaryFactory.GetTempData(HttpContext);
            var tempData         = tempDataProvider.Get <TempData>($"update-{model.SessionId}");

            if (tempData == null)
            {
                ModelState.AddModelError("error", "bad upload");
                return(BadRequest(ModelState));
            }
            var index = (int)(model.StartOffset / UploadInnerResponse.BlockSize);
            await BlobProvider.UploadBlockFileAsync(tempData.BlobName, model.Chunk.OpenReadStream(),
                                                    index, token);

            tempDataProvider.Put($"update-{model.SessionId}", tempData);
            return(new UploadStartResponse());
        }