Esempio n. 1
0
 public override async Task FinishUploadAsync(UploadRequestFinish model, string blobName, CancellationToken token)
 {
     if (model is FinishChatUpload chatModel)
     {
         var userId = _userManager.GetLongUserId(User);
         if (userId == chatModel.OtherUser)
         {
             throw new ArgumentException();
         }
         var command = new SendChatFileMessageCommand(blobName, userId, new[] { chatModel.OtherUser });
         await _commandBus.DispatchAsync(command, token);
     }
 }
Esempio n. 2
0
        private async Task <UploadStartResponse> Upload(UploadRequestFinish model, CancellationToken token)
        {
            var tempDataProvider = _tempDataDictionaryFactory.GetTempData(HttpContext);
            var tempData2        = tempDataProvider.Get <TempData>($"update-{model.SessionId}");

            tempDataProvider.Remove($"update-{model.SessionId}");

            var indexes = new List <int>();

            for (double i = 0; i < tempData2.Size; i += UploadInnerResponse.BlockSize)
            {
                indexes.Add((int)(i / UploadInnerResponse.BlockSize));
            }

            //original file name can only have ascii chars. hebrew not supported. remove that
            await BlobProvider.CommitBlockListAsync(tempData2.BlobName, tempData2.MimeType, null, indexes, null, token);

            var result = tempData2.BlobName;

            await FinishUploadAsync(model, result, token);

            return(new UploadStartResponse(result));
        }
        //[HttpPost("upload"), ApiExplorerSettings(IgnoreApi = true)]
        private async Task <UploadEndResponce> Upload(UploadRequestFinish model, CancellationToken token)
        {
            var tempDataProvider = _tempDataDictionaryFactory.GetTempData(HttpContext);
            var tempData2        = tempDataProvider.Get <TempData>($"update-{model.SessionId}");

            tempDataProvider.Remove($"update-{model.SessionId}");

            var indexes = new List <int>();

            for (double i = 0; i < tempData2.Size; i += UploadInnerResponse.BlockSize)
            {
                indexes.Add((int)(i / UploadInnerResponse.BlockSize));
            }

            //original file name can only have ascii chars. hebrew not supported. remove that
            await _blobProvider.CommitBlockListAsync(tempData2.BlobName, tempData2.MimeType, null, indexes, TimeSpan.FromDays(365), token);

            var bolobUri = _blobProvider.GetBlobUrl(tempData2.BlobName);

            //var preview = BlobProvider.GeneratePreviewLink(bolobUri,
            //                TimeSpan.FromDays(30));
            return(new UploadEndResponce(bolobUri));
        }
Esempio n. 4
0
 public override Task FinishUploadAsync(UploadRequestFinish model, string blobName, CancellationToken token)
 {
     return(System.Threading.Tasks.Task.CompletedTask);
 }
Esempio n. 5
0
 public abstract Task FinishUploadAsync(UploadRequestFinish model, string blobName, CancellationToken token);