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

fileName.OpenReadStream is used

parent 0883f181
......@@ -7,6 +7,7 @@ using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;
using Dicom;
using Dicom.Network.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
......@@ -52,15 +53,12 @@ namespace SendFileWebapi.Controllers
inputsDto.FileNames.ToObservable()
.Select(fileName => Observable.FromAsync(async () =>
{
FileStream fileStream = null;
using (var stream = new FileStream(fileName.FileName, FileMode.Create))
using (var stream = fileName.OpenReadStream())
{
await fileName.CopyToAsync(stream);
fileStream = stream;
var request = new Dicom.Network.DicomCStoreRequest(await DicomFile.OpenAsync(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}")))
.Concat()
.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