1. Home
  2. Data
  3. File Storage Services
  4. Overview of trellispark DAS – File Storage Service (DAS-FSS) Implementation
  1. Home
  2. trellispark Architecture
  3. Overview of trellispark DAS – File Storage Service (DAS-FSS) Implementation
  1. Home
  2. Data
  3. Overview of trellispark DAS – File Storage Service (DAS-FSS) Implementation

Overview of trellispark DAS – File Storage Service (DAS-FSS) Implementation

trellispark is able to transfer any type of file, from any device, into secure file storage, and later read, or delete, that file.

Storage Configuration in Workspace Owner

To setup a new storage connection select the Storage tab in Workspace Owner and select the Add new Storage button. From there you can then specify the name of the storage connection and storage type. Different storage types will require different information from that provider to establish a connection, refer to the specific storage type article for more information.

Some storage types can also be public or private. If a private type is selected then files saved will not be publicly available and will be private to the workspace. Public files can be shared to anyone.

Configuring the GI_UploadFile field component

To configure the GI_UploadFile component you only need to create a storage configuration and then use it in the field definition. Refer to the article that details the Upload File’s field definition here.

StorageInformation

StorageInformation is a shared type that is used to store information about a file that is passed between the UX and API. For more detailed information regarding the properties of the type refer to the StorageInformation article.

Storage.cs

Save

public static async Task SaveFile(StorageInformation storageInformation, IDatabase db)
{
    try
    {
        if (storageInformation.WorkspaceGUID != Guid.Empty)
        {
            if (storageInformation.InstanceGUID != Guid.Empty)
            {
                // Check if InstanceData is empty.
                if (storageInformation.StorageDefinition != "<ID />")
                {
                    XElement storageXML = XElement.Parse(storageInformation.StorageDefinition);

                    switch (storageXML.GetElement("Subform", ""))
                    {
                        case "Amazon S3 BLOB":
                            AWSS3Storage.SaveBLOB(storageInformation);
                            break;
                        case "Amazon S3 BLOB PRIVATE":
                            storageInformation.IsFilePublic = false;
                            AWSS3Storage.SaveBLOB(storageInformation);
                            break;
                        case "Azure Container and BLOB":
                            await AzureStorage.SaveBLOB(storageInformation);
                            break;
                        case "Azure Container and BLOB PRIVATE":
                            storageInformation.IsFilePublic = false;
                            await AzureStorage.SaveBLOB(storageInformation);
                            break;
                        case "Azure File Share":
                            await AzureStorage.SaveFileShare(storageInformation);
                            break;
                        case "Google Cloud Storage BLOB":
                            await GCStorage.SaveBLOB(storageInformation);
                            break;
                        case "Google Cloud Storage BLOB PRIVATE":
                            storageInformation.IsFilePublic = false;
                            await GCStorage.SaveBLOB(storageInformation);
                            break;
                        case "Local File":
                            LocalStorage.SaveLocalFile(storageInformation);
                            break;
                        case "Local File PRIVATE":
                            storageInformation.IsFilePublic = false;
                            LocalStorage.SaveLocalFile(storageInformation);
                            break;
                        case "SharePoint":
                            await SharePointStorage.SaveBLOB(storageInformation, db);
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    storageInformation.ErrorMessage = "StorageDefinition is empty";
                }
            }
            else
            {
                storageInformation.ErrorMessage = "No InstanceGUID was assigned";
            }
        }
        else
        {
            storageInformation.ErrorMessage = "No WorkspaceGUID was assigned";
        }
    }
    catch (Exception e)
    {
        storageInformation.ErrorMessage = $"Storage.SaveFile - Unknown error: " + e.ToString();
    }
}

Read

public static async Task ReadFile(StorageInformation storageInformation, IDatabase db)
{
    try
    {
        if (storageInformation.WorkspaceGUID != Guid.Empty)
        {
            if (storageInformation.InstanceGUID != Guid.Empty)
            {
                // Check if InstanceXML is empty.
                if (storageInformation.StorageDefinition != "<ID />")
                {
                    XElement storageXML = XElement.Parse(storageInformation.StorageDefinition);

                    switch (storageXML.GetElement("Subform", ""))
                    {
                        case "Amazon S3 BLOB":
                        case "Amazon S3 BLOB PRIVATE":
                            AWSS3Storage.ReadBLOB(storageInformation);
                            break;
                        case "Azure Container and BLOB":
                        case "Azure Container and BLOB PRIVATE":
                            await AzureStorage.ReadBLOB(storageInformation);
                            break;

                        case "Azure File Share":
                            await AzureStorage.ReadFileShare(storageInformation);
                            break;
                        case "Google Cloud Storage BLOB":
                        case "Google Cloud Storage BLOB PRIVATE":
                            await GCStorage.ReadBLOB(storageInformation);
                            break;

                        case "Local File":
                        case "Local File PRIVATE":
                            LocalStorage.ReadLocalFile(storageInformation);
                            break;
                        case "SharePoint":
                            await SharePointStorage.ReadBLOB(storageInformation, db);
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                storageInformation.ErrorMessage = "Storage not found";
            }
        }
        else
        {
            storageInformation.ErrorMessage = "No WorkspaceGUID was assigned";
        }
    }
    catch (Exception e)
    {
        storageInformation.ErrorMessage = "Storage.ReadFile - Unknown error: " + e.ToString();
    }
}

Available Storage Options

Below are the available storage options that trellispark supports out of box.

Adding New Storage Options

To create a new storage option, navigate to the Workspace Owner functionality, open the Forms tab and select the Storage concept. On the Overview tab create a new Conditional Filter. specify a Name for the storage type and set the filter type to Content. Next, open the Data Model tab and add all required fields for the new storage type and ensure each field uses the conditional filter you created.

Once you have finished, save your changes and clear the application state.

The next step is to open the Storage class library that trellispark provides and create a new class for your new storage type (e.g., Dropbox). It is up to you to implement the new storage type.

Once you’ve created the implementation for your new storage type open the Storage.cs class and update the switch statement in the ReadFile and SaveFile methods to include your new storage type. The case name needs to match the name of the conditional filter you created previously.

It is highly encouraged that you also create unit tests for your new storage type, the Storage class library also includes a Test-Storage project that contains unit tests for all the storage types trellispark supports.

Updated on February 2, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment