Commit 25fa9324 authored by Mahmoud Bakhtvar's avatar Mahmoud Bakhtvar

fileName.OpenReadStream is used

parent 0883f181
...@@ -7,6 +7,7 @@ using System.Reactive.Linq; ...@@ -7,6 +7,7 @@ using System.Reactive.Linq;
using System.Reactive.Threading.Tasks; using System.Reactive.Threading.Tasks;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dicom;
using Dicom.Network.Client; using Dicom.Network.Client;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
...@@ -52,15 +53,12 @@ namespace SendFileWebapi.Controllers ...@@ -52,15 +53,12 @@ namespace SendFileWebapi.Controllers
inputsDto.FileNames.ToObservable() inputsDto.FileNames.ToObservable()
.Select(fileName => Observable.FromAsync(async () => .Select(fileName => Observable.FromAsync(async () =>
{ {
FileStream fileStream = null; using (var stream = fileName.OpenReadStream())
using (var stream = new FileStream(fileName.FileName, FileMode.Create))
{ {
await fileName.CopyToAsync(stream); var request = new Dicom.Network.DicomCStoreRequest(await DicomFile.OpenAsync(stream));
fileStream = stream; await client.AddRequestAsync(request);
await client.SendAsync();
} }
var request = new Dicom.Network.DicomCStoreRequest(fileStream.Name);
await client.AddRequestAsync(request);
await client.SendAsync();
}).Select(x => fileName.FileName).Catch<string, Exception>(exp => throw new Exception($"failed to send: {fileName}, with error:{exp.Message}"))) }).Select(x => fileName.FileName).Catch<string, Exception>(exp => throw new Exception($"failed to send: {fileName}, with error:{exp.Message}")))
.Concat() .Concat()
.Subscribe( .Subscribe(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment