예제 #1
0
        public async Task <UploadStartResponse> UploadDropBoxAsync([FromBody] DropBoxRequest model,
                                                                   [FromServices] IRestClient client,
                                                                   [FromServices] IDocumentDirectoryBlobProvider documentDirectoryBlobProvider,
                                                                   CancellationToken token)
        {
            var(stream, _) = await client.DownloadStreamAsync(model.Link, token);

            var blobName = BlobFileName(Guid.NewGuid(), model.Name);
            await documentDirectoryBlobProvider.UploadStreamAsync(blobName, stream, token : token);

            return(new UploadStartResponse(blobName));
        }
예제 #2
0
        public async Task <IActionResult> UploadAsync([Required] IFormFile file,
                                                      [FromServices] IDocumentDirectoryBlobProvider blobProvider,
                                                      CancellationToken token)
        {
            var fileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            await blobProvider
            .UploadStreamAsync(fileName, file.OpenReadStream(), file.ContentType, TimeSpan.FromSeconds(60 * 24), token);

            var uri  = blobProvider.GetBlobUrl(fileName);
            var link = blobProvider.GeneratePreviewLink(uri, TimeSpan.FromDays(1));

            return(Ok(new
            {
                link
            }));
        }