Skip to content

Commit 3ee130d

Browse files
committed
File download from WebClient to use HttpClient
1 parent 14a5b84 commit 3ee130d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Blogifier.Core/Providers/StorageProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ public async Task<string> UploadFromWeb(Uri requestUri, string root, string path
124124
Path.Combine(_storageRoot, fileName) :
125125
Path.Combine(_storageRoot, path + _slash + fileName);
126126

127-
using (WebClient client = new WebClient())
127+
HttpClient client = new HttpClient();
128+
var response = await client.GetAsync(requestUri);
129+
using (var fs = new FileStream(filePath, FileMode.CreateNew))
128130
{
129-
client.DownloadFile(requestUri, filePath);
131+
await response.Content.CopyToAsync(fs);
130132
return await Task.FromResult($"![{fileName}]({root}{PathToUrl(filePath)})");
131133
}
132134
}

src/Blogifier/Blog.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)