Connect to Windows shared folder
There are several ways to download files from a Windows shared folder (SMB).
Mount folder to application server
You can mount a shared folder to the Linux server with the Intelligent Automation Cloud installation.
Read files using RPA
You can read files and upload them to S3 using RPA. Run a Groovy script on the RPA server, read a file, and save it to the S3 folder.
See the script
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name="test_node_id">
<template>${test_node_id}</template>
</var-def>
<var-def name="file_name">
<template>${file_name}</template>
</var-def>
<script><![CDATA[
import com.thoughtworks.selenium.*;
import org.openqa.selenium.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
Integer ELEMENT_TIMEOUT = 15;
Integer PAGE_TIMEOUT = 40;
Integer SMART_WAIT = 60;
byte[] entryPasisingData = null;
public byte[] readDataFromFile(String fileName){
byte[] byteArray = null;
String byteString = (String) autoitDriver.executeScript(
"byte[] result=java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(\"C:/Users/\"+System.getProperty(\"user.name\")+\"/Downloads/"
+ fileName + "\"));\n"
+ "byte[] encoded=org.apache.commons.codec.binary.Base64.encodeBase64(result);\n"
+ "return new String(encoded);",
new String[] { "GROOVY" });
byteArray = Base64.decodeBase64(byteString.getBytes());
return byteArray;
}
]]></script>
<selenium-flow>
<selenium name="aDriver" browser="autoit" close-on-completion="true" start-in-private="false" node-id="${test_node_id}">
<script></script>
</selenium>
</selenium-flow>
<var-def name="file_url">
<s3 bucket="screenshots">
<s3-put path="s3_file_older/${file_name}" content-type="application/octet-stream" content-disposition="inline" acl="PublicRead">
<script return='entryPasisingData' />
It opens the file from C:/users/user_name_profile/Downloads. Put the file into this folder only. The node_id property helps to specify a particular RPA node ID to launch and view this sample.
tip
To extract files from a shared folder using the SMB protocol and store the files on S3, see the Share Folder connector description.