Browse Source

Merge pull request #8308 from abpframework/docs-update

Update Application-Services.md
pull/8312/head
Ahmet Çotur 5 years ago
committed by GitHub
parent
commit
aa2fec59ac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      docs/en/Application-Services.md

48
docs/en/Application-Services.md

@ -468,10 +468,37 @@ namespace MyProject.Test
{
Task Upload(Guid id, IRemoteStreamContent streamContent);
Task<IRemoteStreamContent> 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<IRemoteStreamContent> 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<AbpAspNetCoreMvcOptions>(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();
}
}
}
}
````

Loading…
Cancel
Save