Configure the File Upload Folder

When building a spider web awarding that requires users to upload or download files (documents, images, etc.), file storage can be an important aspect of the application architecture.

Where Should I Store Files?

FintechOS platform supports multiple storage providers for storing the uploaded or generated user files. When building web applications using FintechOS engineering science, you've got a few choices for where to store your files:

  • Local File Organization Storage
  • Azure Hulk Storage
  • Amazon S3 Buckets Storage

The local file system refers to either a local path on the application server or a shared folder on the network containing the application server. While it is the default storage provider, you might be running out of deejay infinite or you might notice it a very challenging chore to ensure that files are properly backed upwardly and available at all times.

If y'all'll be storing large blobs of content, you might want to consider one of the other options. Storing files in a file storage service similar Amazon S3 Buckets or Azure Blob is a great option if you'll be storing large blobs of content. Not only you stay rest bodacious that your data is replicated and backed upward, but they also ensure scalability and high availability.

This section walks you lot through the steps needed to configure the "UploadEbs" storage provider /location as needed.

Local File Arrangement Storage

There are no special configurations that have to exist made in order to use it other than setting the name of the root folder.

To gear up the name of the root folder, go to the web.config file, open up it and to the appSettings node, add the awarding setting UploadFolder, as described below:

Copy

                              <configuration>                
 ...
<appSettings>
       ...
<add key = "UploadFolder" value = "path_to_root_folder" />
</appSettings>
</configuration>

Depending on where the root folder resides, make sure that you properly set the value of the UploadFolder setting:

  • subfolder of the awarding folder: "~/path/to/uploadfolder/";
  • local folder on application server, the full path to local folder, like: "c:\path\to\uploadfolder"
  • network shared folder: "\\server\path\to\uploadfolder";

Annotation
If in the web.config file you do not set the UploadFolder setting, it is automatically set to the default value, that is, "~/UploadEBS/".

Automatically Create File Upload Subfolders

IMPORTANT!
This feature is available only for local file organization storage. It is not available for Azure Blob Storage or Amazon S3 Buckets Storage.

You tin automatically group uploaded files into folders based on the final three characters in their file name (excluding the file extension). To do so, add an characteristic-uploadfolder-autocreate-subfolders key with a value of i in the web.config file:

Copy

                              <add                  fundamental                  =                  "characteristic-uploadfolder-autocreate-subfolders"                  value                  =                  "1">                          

This volition save each uploaded file in a -.files\xyz subfolder of the upload folder, where xyz represents the last 3 characters of the file name. For example, a file called MyDoc_0caf99b6-549d-48f7-8747-5e3eb82753fd.txt will be saved in a folder structure like to:

Copy

              ...\
    UploadEBS\
        -.files\
3fd\
                MyDoc_0caf99b6-549d-48f7-8747-5e3eb82753fd.txt

Setting the characteristic-uploadfolder-autocreate-subfolders key value to 0 disables the feature.

This characteristic is backward compatible. If a requested file is not stored in the in a higher place folder structure, it will exist read from the main upload binder or the entity specific upload binder respectively.

Azure Blob Storage

To configure FintechOS to shop user files in Azure Blob, follow these steps:

  1. Become to the spider web.config file and open it.
  2. Add a ftosStorageService department to the <configSections> chemical element:
  3. Copy

                                      <configuration>                  
    <configSections>
                ...
    <section proper name = "ftosStorageService" blazon = "EBS.Core.Utils.Services.Config.StorageServiceConfigSection, EBS.Core.Utils" />
    </configSections>
    <configuration>
  4. Add a ftosStorageService section (note the AzureBlob type) as child of <configuration> chemical element:
  5. Copy

                                      <configuration>                  
     ...
    <ftosStorageService type = "AzureBlob">
    <settings>
    <setting name = "connectionString" value = "connection_string" />
    <setting name = "rootContainer" value = "root_container" />
    </settings>
    </ftosStorageService>
    </configuration>

where:

  • connectionString is the connection string FintechOS is using to connect to an Azure Blob container;
  • rootContainer is the root container proper noun where the user files will exist stored.

Azure Resource Manager templates back up

To enable automatic deployment through ARM templates, the connectionString and rootContainer settings must be configured in the <appSettings> element of the web.config file:

Re-create

                              <appSettings>                
...
<add primal = "ftosStorageService-AzureBlob-connectionString" value = "connection_string" />
<add fundamental = "ftosStorageService-AzureBlob-rootContainer" value = "root_container" />
</appSettings>

IMPORTANT!
Values prepare in the <appSettings> keys have precedence over the values prepare in the <ftosStorageService> settings node.

Amazon S3 Buckets Storage

To configure FintechOS to store user files in Amazon S3 Buckets, follow these steps:

  1. Go to the spider web.config file and open it.
  2. To the <configSections> element, add the following two sections: ftosStorageService and aws, equally described beneath:
  3. Copy

                                      <configuration>                  
    <configSections>
            ...
    <section name = "ftosStorageService" blazon = "EBS.Core.Utils.Services.Config.StorageServiceConfigSection, EBS.Core.Utils" />
    <department proper noun = "aws" type = "Amazon.AWSSection, AWSSDK.Core" />
    </configSections>
    <configuration>
  4. Add <ftosStorageService> tag (note the AmazonS3Bucket blazon) as child of configuration element:
  5. Re-create

                                      <configuration>                  
            ...
    <ftosStorageService type = "AmazonS3Bucket">
    <settings>
    <setting name = "AWSAccessKey" value = "access_key" />
    <setting proper noun = "AWSSecretKey" value = "secret_key" />
    <setting proper noun = "BucketName" value = "bucket_name" />
    </settings>
    </ftosStorageService>
    </configuration>

    where:

    AWSAccessKey and AWSSecretKey are used by FTOS to sign the requests made to AWS. For more information, see Access Keys (Access Fundamental ID and Secret Access Key).

    BucketName is the root saucepan name where the user files will be stored.

  6. Add together the aws department as kid of the configuration chemical element:
  7. Copy

                                      <configuration>                  
    ...
    <aws region = "aws_region">
    </aws>
    </configuration>

NOTE
The but required aspect is region. For a consummate list of available regions, encounter Amazon documentation, department Regions, Availability Zones, and Local Zones. The region attribute must accept one of the values from the cavalcade "Region". E.chiliad.: <aws region="european union-central-one"></aws>

For a list of allowed elements in the AWS section, see Configuration Files Reference for AWS SDK for .NET.