publish
plugins.it2be_aws.AWSS3 info


Servoy Methods Summary
Boolean addObject( JSFile, String, String )
Boolean deleteObject( String, String )
byte[] getObject( String, String )
String getSignedURLForDownload( String, String )
String getSignedURLForDownload( String, String, Number, String, String )
String getSignedURLForDownload( String, String, String, String )
String getSignedURLForDownload( String, String, Number )
S3UploadURLResult getSignedURLForUpload( String, String, String, String, String, String )
S3UploadURLResult getSignedURLForUpload( String, String, String, String )
S3UploadURLResult getSignedURLForUpload( String, String, String, String, Number, String, String )
S3UploadURLResult getSignedURLForUpload( String, String, String, String, Number )
Array<S3File> listObjects( String )


Servoy Methods Details


addObject
Boolean  addObject( JSFile, String, String )
Uploads the given file to S3 at the provided path.
Parameters
JSFile  file  plugins.file.JSFile to upload
String  bucket  S3 bucket name
String  path  Path inside S3 (include the desired file name in the path!)

Returns
Boolean  boolean indicator of whether the upload was successful or not

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var myFile = plugins.file.convertToJSFile("C:\\path\\to\\my\\file.txt");
s3Client.addObject(myFile, "my-bucket-name", "/path/inside/bucket/new_file.txt")


deleteObject
Boolean  deleteObject( String, String )
Deletes the given file from S3 at the provided path.
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3

Returns
Boolean  boolean indicator of whether the upload was successful or not

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
s3Client.deleteObject("my-bucket-name", "/path/inside/bucket/file.txt")


getObject
byte[]  getObject( String, String )
Retrieves the bytes of the given file from S3 at the provided path.
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3

Returns
byte[]  byte array if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var fileBytes = s3Client.getObject("my-bucket-name", "/path/inside/bucket/file.txt")


getSignedURLForDownload
String  getSignedURLForDownload( String, String )
Generates a signed URL used for downloading for the given file, valid for 15 minutes, using the same credentials provided to the setCredentials() call. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3

Returns
String  Signed URL if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForDownload("my-bucket-name", "/path/inside/bucket/file.txt")


getSignedURLForDownload
String  getSignedURLForDownload( String, String, Number, String, String )
Generates a signed URL used for downloading for the given file, valid for a provided number of minutes, using the provided credentials. NOTE: If you use this method, please store the access key and secret key securely. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3
Number  expiresInMinutes
String  awsAccessKeyId
String  awsSecretAccessKey

Returns
String  Signed URL if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForDownload("my-bucket-name", "/path/inside/bucket/file.txt", 2, "my-access-key", "my-secret-access-key")


getSignedURLForDownload
String  getSignedURLForDownload( String, String, String, String )
Generates a signed URL used for downloading for the given file, valid for 15 minutes, using the provided credentials. NOTE: If you use this method, please store the access key and secret key securely. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3
String  awsAccessKeyId  AWS access key
String  awsSecretAccessKey  AWS secret key

Returns
String  Signed URL if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForDownload("my-bucket-name", "/path/inside/bucket/file.txt", "my-access-key", "my-secret-access-key")


getSignedURLForDownload
String  getSignedURLForDownload( String, String, Number )
Generates a signed URL used for downloading for the given file, valid for a provided number of minutes, using the same credentials provided to the setCredentials() call. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3
Number  expiresInMinutes  Number of minutes before the signed URL expires

Returns
String  Signed URL if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForDownload("my-bucket-name", "/path/inside/bucket/file.txt", 2)


getSignedURLForUpload
S3UploadURLResult  getSignedURLForUpload( String, String, String, String, String, String )
Generates a signed URL used for uploading a given file, valid for 15 minutes, using the provided credentials. NOTE: If you use this method, please store the access key and secret key securely. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3 (excluding the file name)
String  fileName  Name of the destination file in S3
String  contentType  Content-Type of the file.
String  awsAccessKeyId  AWS access key
String  awsSecretAccessKey  AWS secret key

Returns
S3UploadURLResult  Object containing the URL, file name, and expiration minutes if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForUpload("my-bucket-name", "/path/inside/bucket/", "my_file.txt", "text/plain", "my-access-key", "my-secret-access-key");

var httpClient = plugins.http.createNewHttpClient();
var myFileToUpload = plugins.file.convertToJSFile("C:\\path\\to\\file.txt");
var putRequest = httpClient.createPutRequest(signedUrl.url);
putRequest.addHeader("Content-Type", myFileToUpload.getContentType());
putRequest.setFile(myFileToUpload);
var response = putRequest.executeRequest();


getSignedURLForUpload
S3UploadURLResult  getSignedURLForUpload( String, String, String, String )
Generates a signed URL used for uploading a given file, valid for 15 minutes, using the same credentials provided to the setCredentials() call. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3 (excluding the file name)
String  fileName  Name of the destination file in S3
String  contentType  Content-Type of the file.

Returns
S3UploadURLResult  Object containing the URL, file name, and expiration minutes if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForUpload("my-bucket-name", "/path/inside/bucket/", "my_file.txt", "text/plain");

var httpClient = plugins.http.createNewHttpClient();
var myFileToUpload = plugins.file.convertToJSFile("C:\\path\\to\\file.txt");
var putRequest = httpClient.createPutRequest(signedUrl.url);
putRequest.addHeader("Content-Type", myFileToUpload.getContentType());
putRequest.setFile(myFileToUpload);
var response = putRequest.executeRequest();


getSignedURLForUpload
S3UploadURLResult  getSignedURLForUpload( String, String, String, String, Number, String, String )
Generates a signed URL used for uploading a given file, valid for a given number of minutes, using the provided credentials. NOTE: If you use this method, please store the access key and secret key securely. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3 (excluding the file name)
String  fileName  Name of the destination file in S3
String  contentType  Content-Type of the file.
Number  expiresInMinutes  Number of minutes before the signed URL expires
String  awsAccessKeyId  AWS access key
String  awsSecretAccessKey  AWS secret key

Returns
S3UploadURLResult  Object containing the URL, file name, and expiration minutes if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForUpload("my-bucket-name", "/path/inside/bucket/", "my_file.txt", "text/plain", 2, "my-access-key", "my-secret-access-key");

var httpClient = plugins.http.createNewHttpClient();
var myFileToUpload = plugins.file.convertToJSFile("C:\\path\\to\\file.txt");
var putRequest = httpClient.createPutRequest(signedUrl.url);
putRequest.addHeader("Content-Type", myFileToUpload.getContentType());
putRequest.setFile(myFileToUpload);
var response = putRequest.executeRequest();


getSignedURLForUpload
S3UploadURLResult  getSignedURLForUpload( String, String, String, String, Number )
Generates a signed URL used for uploading a given file, valid for a given number of minutes, using the same credentials provided to the setCredentials() call. For more information on signed URLs, see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html
Parameters
String  bucket  S3 bucket name
String  path  Path inside S3 (excluding the file name)
String  fileName  Name of the destination file in S3
String  contentType  Content-Type of the file.
Number  expiresInMinutes  Number of minutes before the signed URL expires

Returns
S3UploadURLResult  Object containing the URL, file name, and expiration minutes if successful, otherwise null

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var signedUrl = s3Client.getSignedURLForUpload("my-bucket-name", "/path/inside/bucket/", "my_file.txt", "text/plain", 2);

var httpClient = plugins.http.createNewHttpClient();
var myFileToUpload = plugins.file.convertToJSFile("C:\\path\\to\\file.txt");
var putRequest = httpClient.createPutRequest(signedUrl.url);
putRequest.addHeader("Content-Type", myFileToUpload.getContentType());
putRequest.setFile(myFileToUpload);
var response = putRequest.executeRequest();


listObjects
Array<S3File>  listObjects( String )
Lists the objects in the provided bucket.
Parameters
String  bucketName  S3 bucket name

Returns
Array<S3File>  S3File objects, or null if there was an error.

Supported Clients
SmartClient, WebClient, NGClient

Sample
plugins.it2be_aws.setCredentials();
var s3Client = plugins.it2be_aws.newS3(plugins.it2be_aws.AWS_REGIONS.US_EAST_N_VIRGINIA);
var objects = s3Client.listObjects("my-bucket-name");