The AWSS3Connector extension allows uploading files to the AWS S3 service.
To use the AWSS3Connector extension, the following properties need to be configured (all of them are required):
com.nm.extensions.awss3connector.accessKey: AWS access key (aka Access Key ID, example: AMIAJJHUSKCHKDQYE7EA) to access the S3 service.com.nm.extensions.awss3connector.secretKey: AWS secret key (aka Secret Access Key, example: Kyb+/MY17dQ3cQepM4Psckuq/m+oSN5y+WPXqlh+) to access the S3 service.com.nm.extensions.awss3connector.region: AWS region used to access the S3 service. E.g. eu-central-1com.nm.extensions.awss3connector.bucket: AWS S3 bucket name to store the upload files. E.g. client-onboarding-bucket
The AWS access key and secret key, after they are manually configured, are encrypted, stored in the Appway internal vault, and marked as [ENCRYPTED].
To upload files to the AWS S3 service, the following Script Function is provided:
AWSS3Connector:UploadLocalFile(LocalFile $file, String $path)
where $file is the LocalFile to upload and $path is the path (aka key) in the configured S3 bucket.
There is no return value.
If an exception occurs, an NmRuntimeException is thrown.
The following code snippet will upload the locally stored file /tmp/test.txt to the configured S3 bucket under the given path uploads/test.txt:
LocalFile $file := NewObject(LocalFile, '/tmp/test.txt');
AWSS3Connector:UploadLocalFile($file, 'uploads/test.txt');
Consider the following:
- If the file (and directory) do not exist yet, they are created automatically.
- If the file (and directory) already exist, the file is overwritten.