diff --git a/docs/en/Application-Services.md b/docs/en/Application-Services.md index 5d779ec8c9..c6108c477e 100644 --- a/docs/en/Application-Services.md +++ b/docs/en/Application-Services.md @@ -468,10 +468,37 @@ namespace MyProject.Test { Task Upload(Guid id, IRemoteStreamContent streamContent); Task Download(Guid id); + + Task CreateFile(CreateFileInput input); + Task CreateMultipleFile(CreateMultipleFileInput input); + } + + public class CreateFileInput + { + public Guid Id { get; set; } + + public IRemoteStreamContent Content { get; set; } + } + + public class CreateMultipleFileInput + { + public Guid Id { get; set; } + + public IEnumerable Contents { get; set; } } } ```` +**You need to configure `AbpAspNetCoreMvcOptions` to add DTO class to `FormBodyBindingIgnoredTypes` to use `IRemoteStreamContent` in** **DTO ([Data Transfer Object](Data-Transfer-Objects.md))** + +````csharp +Configure(options => +{ + options.ConventionalControllers.FormBodyBindingIgnoredTypes.Add(typeof(CreateFileInput)); + options.ConventionalControllers.FormBodyBindingIgnoredTypes.Add(typeof(CreateMultipleFileInput)); +}); +```` + **Example: Application Service Implementation that can be used to get and return streams** ````csharp @@ -504,6 +531,27 @@ namespace MyProject.Test await fs.FlushAsync(); } } + + public async Task CreateFileAsync(CreateFileInput input) + { + using (var fs = new FileStream("C:\\Temp\\" + input.Id + ".blob", FileMode.Create)) + { + await input.Content.GetStream().CopyToAsync(fs); + await fs.FlushAsync(); + } + } + + public async Task CreateMultipleFileAsync(CreateMultipleFileInput input) + { + using (var fs = new FileStream("C:\\Temp\\" + input.Id + ".blob", FileMode.Append)) + { + foreach (var content in input.Contents) + { + await content.GetStream().CopyToAsync(fs); + } + await fs.FlushAsync(); + } + } } } ````