Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/Weikio.ApiFramework.Plugins.Files/FilesReadWrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ public async Task Create([FromForm] FileContent content)
{
if (string.IsNullOrWhiteSpace(content?.FilePath))
{
throw new ArgumentException("File name must be supplied.", nameof(content.FilePath));
throw new ArgumentException("File name must be supplied. Ensure file name is given in form data format.", nameof(content.FilePath));
}

var fullPath = Path.Combine(Configuration?.RootPath ?? "", content.FilePath);

using (var stream = System.IO.File.OpenWrite(fullPath))
if(content.Data is null)
{
await content.Data.CopyToAsync(stream);
throw new ArgumentException("Data must be supplied.", nameof(content.Data));
}

var fullPath = Path.Combine(Configuration?.RootPath ?? "", content.FilePath);

using var stream = File.OpenWrite(fullPath);
await content.Data.CopyToAsync(stream);
}

[HttpDelete]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Weikio.ApiFramework.Abstractions.DependencyInjection;
using Weikio.ApiFramework.SDK;

Expand Down