Once you have created the Web API service application, you can optionally configure Storage in it. Storage serves as a repository for data, on the server side or remote location. It provides data from database or data files to the client applications. The client applications use this data and consume the Rest API service through GET request, to generate, convert, and merge excel files in desired format. For more information, see Excel Services.
Client application fetches data/file from the configured storage once user makes a GET request. Your storage can be a remote or local storage. Remote storage could reside on cloud or on a different server than your configured host service. Whereas, local storage resides on the same server where host service is deployed. This section demonstrates how to create and configure a local storage folder within your service app. While, the following sections discuss configuring server side connection string and .NET collections to configure local storage.
Complete the following steps to configure local storage in Web API service created in Configuring Web API topic.
C# |
Copy Code
|
---|---|
var folder = GetFullRoot("Files"); |
C# |
Copy Code
|
---|---|
private static string GetFullRoot(string root) { var applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; var fullRoot = Path.GetFullPath(Path.Combine(applicationBase, root)); if (!fullRoot.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) { // When we do matches in GetFullPath, we want to only match full directory names. fullRoot += Path.DirectorySeparatorChar; } return fullRoot; } |
C# |
Copy Code
|
---|---|
app.UseStorageProviders() .AddDiskStorage("fullRoot", GetFullRoot("Files")); |
This method takes root name and full path of the storage. Give a desired name to your storage folder, for example "root" in this case.