-
Notifications
You must be signed in to change notification settings - Fork 191
Conversation
using Microsoft.AspNet.Http.Internal; | ||
|
||
namespace Microsoft.AspNet.Http.Features.Internal | ||
{ | ||
public class FormFile : IFormFile | ||
{ | ||
// Stream.CopyTo method uses 80KB as the default buffer size. | ||
private const int DefaultBufferSize = 80*1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces
f5df67e
to
c7779ff
Compare
/// <param name="cancellationToken"></param> | ||
public async Task SaveAsAsync(string path, CancellationToken cancellationToken) | ||
{ | ||
using (var fileStream = new FileStream(path, FileMode.Create)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use File.Create instead
c7779ff
to
60f2175
Compare
/// <param name="path">The path of the file to create.</param> | ||
public void SaveAs(string path) | ||
{ | ||
using (var fileStream = new FileStream(path, FileMode.Create)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use File.Create instead
60f2175
to
5c5666e
Compare
I like it |
/// </summary> | ||
/// <param name="path">The path of the file to create.</param> | ||
/// <param name="cancellationToken"></param> | ||
Task SaveAsAsync(string path, CancellationToken cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern we chose for cancellation token was to:
Task SaveAsAsync(string path, CancellationToken cancellationToken = default(CancellationToken)));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aigh. I thought optional params were frowned upon 😦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
619fde9
to
8e6dda3
Compare
@khellang squash the commits and I'll merge it. Let's see what breaks! |
8e6dda3
to
009cf4a
Compare
Done ✨ |
I guess this warrants an announcement? |
/// <param name="cancellationToken"></param> | ||
public async Task SaveAsAsync(string path, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
using (var fileStream = File.Create(path, DefaultBufferSize)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost done. You need to pass FileOptions
and pass the async flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
009cf4a
to
4b64d18
Compare
Promote IFormFile extension methods
One alternative to fix half of #527 ✨