Configuration.ExternalStorage External Object

Official Content
This documentation is valid for:

With this functionality, you can change at runtime the Storage Provider set in the Storage Provider property, change its settings, or connect to other Storage Providers configured in cloudservices.config.

An external object called GeneXus.Common.Configuration.ExternalStorage that is part of the GeneXus Core module exposes all the methods needed for this functionality.

image_202061995517_1_png image_202061711259_1_png

Methods

Create method

Returns an instance of the Storage Provider that is being used in the programs as configured in the Storage Provider property configured in the environment.

Return value Boolean
Parameters ProviderType:StorageProviderType,
Properties:Properties Data Type,
OutStorageProvider:StorageProvider,
OutMessages:Messages

Warning: Temporary Restriction: The &Properties input must include authentication credentials for your provider.


Connect method

Given a ProfileName defined in CloudServices.config, returns an instance of the corresponding Storage Provider.

Return value Boolean
Parameters ProfileName:Character,
Properties:Properties Data Type,
OutStorageProvider:StorageProvider,
OutMessages:Messages

Note: Temporary Restriction: The only supported value for ProfileName is 'Default'.

Domains

StorageProvider domain

Enumerated domain with the Storage Provider Types available in Storage Provider property:

Amazon_S3  
Box Not supported
Google_CloudStorage   
IBM_Bluemix Not supported
IBM_ObjectStorage  
Microsoft_Azure  
OpenStack Not supported

Note: Supported values depend on the existence of the corresponding implementation in Storage Provider property for the generator or installation that is being used.

Examples

In these samples:

  • &Properties is of Properties Data Type
  • &StorageProvider, &fromStorageProvider, &toStorageProvider are of Storage Provider API data type
  • &ExternalStorage, &fromExternalStorage, &toExternalStorage are of GeneXus.Common.Configuration.ExternalStorage data type
  • &Messages is of GeneXus.Common.Messages data type.

Use case 1: Just change a property (i.e.: the Bucket name)

&Properties = new()
&Properties.set(!"BUCKET_NAME", !"my-bucket")
if &ExternalStorage.Connect(!"Default", &Properties, &StorageProvider, &Messages)
     //{{ use &StorageProvider }}
endIf

Note: "Default" makes reference to the one defined in the Storage Provider property at design time.

Use case 2: Completely configure a provider at runtime

&Properties = new()
&Properties.set(!"STORAGE_PROVIDER_ACCESSKEYID", !"{access-key-id_by-S3}")
&Properties.set(!"STORAGE_PROVIDER_SECRETACCESSKEY", !"{secret-access-key_by-S3}")
&Properties.set(!"STORAGE_ENDPOINT", !"{endpoint_by-S3}")
if &ExternalStorage.Create(StorageProviderType.Amazon_S3, &Properties, &StorageProvider, &Messages)
     //{{ use &StorageProvider }}
endIf

Note: This case is useful for multitenant scenarios, where for each tenant you need to use another storage environment.

Caso 3: Copy objects (files) from one Bucket or storage environment to another

&AWSProperties.clear()
&AzureProperties.clear()
if &ExternalStorage.Create(StorageProviderType.Amazon_S3, &AWSProperties, &OutStorageProvider, &OutMessages)
    //{{ &OutStorageProvider points to Amazon, now you can download the files from there }}
    if &ExternalStorage.Create(StorageProviderType.Microsoft_Azure, &AzureProperties, &OutStorageProvider, &OutMessages)    
        //{{ &OutStorageProvider now points to Azure, and you can upload the previously downloaded files to Azure }}
    endIf 
endIf

Warning: Only one instance of StorageProvider Data type can be used in a program. That is why the same variable &OutStorageProvider has been used in case 3.

Scope

Cases 1 and 2 are supported in .NET, .NET Core, and Java generators.

Case 3 is, as of GeneXus 16 Upgrade 10, only supported in .NET and .NET Core generators.

Availability

This feature is available since GeneXus 16 upgrade 10.

See Also