Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Restricting file uploads by type using filters


In this recipe, we will create a file upload service that restricts allowed media types to a predefined whitelist. This will be done by using a request filter attribute and applying it to a service that handles file uploading.

Getting ready

If you are using a non-express version of Visual Studio, you can start this recipe using ServiceStackVS and create a project based on ServiceStack ASP.NET with the Bootstrap template or one of the others that supports Razor by default. If you are using an express version of Visual Studio, please follow Creating a ServiceStack solution with Visual Studio and NuGet in Appendix A, Getting Started and start from the second instruction in the How to do it... section that is follows.

How to do it…

  1. Create a new project using the ServiceStackVS template and based on ServiceStack ASP.NET with Bootstrap, as follows:

  2. Create the file upload request and response objects with the configured Route of /upload within the ServiceModel...