S3 inside robot plugin
There is a special class for working with S3 on the RPA Bot side (Windows RPA Server).
Call example
<robotics-flow>
<robot driver="universal">
<script></script>
</robot>
</robotics-flow>
Download file
The method for downloading a file from S3 to the RPA Bot side returns absolute path to a local file.
The attributes are enumerated in the table below.
| Parameter | Required | Description |
|---|---|---|
s3EndpointUrl | yes | url to S3 |
signerType | yes | S3 signature types (S3SignerType) |
accessKey | yes | access key to S3 bucket |
secretKey | yes | secret key to S3 bucket |
bucket | yes | bucket name |
s3Key | yes | path to file on bucket |
targetPath | yes | path to destination file |
timeout | no | timeout, i.e., how long to wait for response (in milliseconds) |
Expand to see the example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<secure-store-get alias="s3-keys" />
<robotics-flow>
<robot driver="universal">
<script></script>
</robot>
</robotics-flow>
<export include-original-data="true">
<single-column name="FileLocation" value="${FileLocation.toString()}"/>
</export>
</config>
Upload file
The method for uploading a file to S3 on the RPA Bot side returns a link to the uploaded file.
The attributes are given in the table below.
| Parameter | Required | Description |
|---|---|---|
s3EndpointUrl | yes | url to S3 |
signerType | yes | S3 signature types (S3SignerType) |
accessKey | yes | access key to S3 bucket |
secretKey | yes | secret key to S3 bucket |
bucket | yes | bucket name |
s3Key | yes | path to file on bucket |
sourcePath | yes | path to source file |
strategy | yes | ENUM (S3OverwriteStrategy) for values OVERWRITE, SKIP, and FAIL |
timeout | no | timeout, i.e., how long to wait for response (in milliseconds) |
Expand to see the example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<var-def name="sikuliScreenshotAllScreen">
<![CDATA[
import org.sikuli.script.*;
Screen screen = new Screen();
return screen.capture(screen.getBounds()).getFile();
]]>
</var-def>
<var-def name="script_code">
<![CDATA[
import java.net.InetAddress;
InetAddress inetAddress = InetAddress.getLocalHost();
return inetAddress.getHostAddress();
]]>
</var-def>
<secure-store-get alias="s3-keys" />
<robotics-flow>
<robot driver="universal">
<script></script>
</robot>
</robotics-flow>
<export include-original-data="true">
<single-column name="s3_file_location" value="${s3FileLocation.toString()}"/>
</export>
</config>
Create folder
The method for creating a folder in S3 on the RPA Bot side returns a link to the created folder.
The attributes are given in the table below.
| Parameter | Required | Description |
|---|---|---|
s3EndpointUrl | yes | url to S3 |
signerType | yes | S3 signature types (S3SignerType) |
accessKey | yes | access key to S3 bucket |
secretKey | yes | secret key to S3 bucket |
bucket | yes | bucket name |
s3Key | yes | path to folder on bucket |
Expand to see the example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<secure-store-get alias="s3-keys" />
<robotics-flow>
<robot driver="universal">
<script></script>
</robot>
</robotics-flow>
<export include-original-data="true">
<single-column name="FolderLocation" value="${FolderLocation.toString()}"/>
</export>
</config>
Delete folder or file
The method for deleting a folder or a file in S3 on the RPA Bot side has the following attributes.
| Parameter | Required | Description |
|---|---|---|
s3EndpointUrl | yes | url to S3 |
signerType | yes | S3 signature types (S3SignerType) |
accessKey | yes | access key to S3 bucket |
secretKey | yes | secret key to S3 bucket |
bucket | yes | bucket name |
s3Key | yes | path to folder or file on bucket |
Expand to see the example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<secure-store-get alias="s3-keys" />
<robotics-flow>
<robot driver="universal">
<script></script>
</robot>
</robotics-flow>
<export include-original-data="true"/>
</config>
Get directory list
The method for getting a list of folders and files from S3 bucket returns a list of JSON objects with information about an S3 object (a file or a folder).
The attributes are given in the table below.
| Parameter | Required | Description |
|---|---|---|
s3EndpointUrl | yes | url to S3 |
signerType | yes | S3 signature types (S3SignerType) |
accessKey | yes | access key to S3 bucket |
secretKey | yes | secret key to S3 bucket |
bucket | yes | bucket name |
s3Key | yes | path to root folder or file on bucket |
Expand to see the example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<secure-store-get alias="s3-keys" />
<robotics-flow>
<robot driver="universal">
<script><![CDATA[
securityMap = secureEntryMap.getWrappedObject();
securityEntry = securityMap.get("s3-keys");
accessKey = securityEntry.getKey().toString();
secretKey = securityEntry.getValue().toString();
inDesktop(){
s3EndpointUrl = "https://s3.amazonaws.com";
signerType = "S3SignerType";
bucket = "testbucket";
s3Key = "screenshots/";
directoryList = S3.directoryListS3(s3EndpointUrl, signerType, accessKey, secretKey, bucket, s3Key);
if(directoryList.size()>0) {
columnSet = new ArrayList(directoryList.get(0).keySet());
} else {
columnSet = new ArrayList();
}
sys.defineVariable("directoryList", directoryList);
sys.defineVariable("columnSet", columnSet)
}
]]></script>
</robot>
</robotics-flow>
<export include-original-data="true">
<multi-column list="${directoryList}" split-results="true">
<loop item="column_name">
<list>
<var name="columnSet"/>
</list>
<body>
<put-to-column-getter name="${column_name}" property="${column_name}" />
</body>
</loop>
</multi-column>
</export>
</config>