Apart from the constructors for the four concrete types, we can use a method File , provided natively from the ControllerBase class, to return a concrete FileResult object.
With the groundwork laid, we can easily write an action method as follows:. In the code above, we first find or generate the requested file from the local file system or a file storage, then read the file content. In the end line 7 , we return a FileContentResult object that is created using the method File byte[] fileContents, string contentType, string fileDownloadName. Note that we should validate the request and user permissions before finding or generating the requested file.
And you can choose to stream the file too. In the File method line 7 , the second parameter contentType is used in the HTTP header to indicate the format of contents transmitted over the internet. You can set the value for contentType according to your file type. In the File method, the third parameter fileDownloadName determines the value for the filename attribute in the content-disposition HTTP response header.
Browsers treat this value as the top priority to dictate the filename when downloading the file. Email us at support craterapp. Docs Github. View Demo Download. Privacy policy. Thank you. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info.
That makes it easy to deliver any common requested for cached responses. Making your representation layer as friendly for the developer to work with is essential. But you want to do this without hindering any of the backend performance. Including an orchestration layer beside the interface can allow you to combine data from various APIs. Let your server do the majority of your work. Your server can help users keep costs low for their network data and also save the battery life on their devices.
Your mobile app will definitely benefit if you can store data remotely on a server or eliminate some difficult tasks to a remote device. Storing data remotely with an API also makes it easy for users to access their information as it gets synced to all of their devices.
Allowing your server to do most of the work will ultimately benefit the developers as well. It will save them time and gives them an opportunity to consolidate some of the coding.
You should leverage the server because the hardware is better than whatever the mobile clients are using to crunch numbers. Performance is key when it comes to choosing a server. Any problems with your server can absolutely destroy your app. Users are impatient. You also want to make sure that the error codes in your programming language make it easy to fix the problem. This will adversely affect your download rates as well as your search ranking.
You also want to keep offline users for all devices in mind. Even when the app is offline, most users would expect it to have some sort of functionality. Contents Exit focus mode. Is this page helpful? Please rate your experience Yes No. Any additional feedback? Tip We recommend creating and using App API tokens to limit the authorization scope to only one app at a time and limit the risk if a token is exposed. Warning Don't embed API tokens into source code.
0コメント