How to provide a local file on your desktop as User-Input to a workflow: The Solution
2016-07-26 02:50 AM
WFA should have an option for providing a local file as input to a workflow and the workflow can
can then fetch the file from the WFA client desktop computer and make it available to my Workflow to compute upon.
Why is this needed?
This can be needed in many cases like.
- The workflow requires a file which is only available to the operator on his desktop.
- I can't copy paste the contents of the local file into Workflow’s string User-Input because the content length is too large. This is also not an otption for file types like PDF, XL etc.
- The WFA windows credentials are not available to the workflow executor to copy the file.
- I have a binary file my local desktop which my workflow needs for execution.
- I have WFA 'Operators' executing the workflows who have the files with them, I can't share WFA credentials for them to login and copy files.
- I want the file to be provided when I want to execute the wokflow.
The Solution Logic:
If you look I basically need a way to securely transfer a file present on my local desktop(windows/linux/mac) to the WFA server using the WFA's browser interface using the credentials only known to the one who owns the files. So I can make use of windows WinSCP .net assemblies. And I can easily setup an sshd server on my desktop client machine. This is all I need and this is the very core-logic behind this solution.
I have a WFA command executing on my WFA server that can remotely connect to my desktop using SCP/SFTP and pull/copy the given file from my desktop to a location on the WFA server. The subsequent commands in the workflow can now make use of this uploaded file as desired.
Prepare your WFA server. One time setup for your WFA server
- You need WinSCP .net assemblies. There is a very useful wrapper written on top of the methods of WinSCP assembly. Download it from here.
- Extract the WinSCP.zip file. This is the Module we need. Copy the folder WinSCP into WFA\POSH\Modules\ .
3, That's all, your WFA server is ready to connect to any desktop using SCP/SFTP/FTP.
Prepare your desktop from where you access the WFA using a browser. The desktop where you have the files you want to upload. One time setup.
- You need to install or setup SSHD or FTP server on your desktop and allow external access. I would recommend SSH as this is secure. SFTP can also be setup. How to set this up?
This step depends on the OS of your desktop.
Windows : There are many SSH Servers available. WinSSHD, FreeSSHD, MobaSSH. Install any one of these. You might have to modify firewall settings to allow incoming requests. Would recommend WinSSHD or OpenSSH for windows.
Linux, Ubuntu : SSH server is available by default. So nothing needed to be done.
Mac : You can use the step given here.
Once ready you should be able to login and access your Desktop using an SSH client like Putty, Bitwise SSH or the like. There are many. If you can't login, you need to get this step right before you proceed.
That's all. Now have a command in WFA which connects to your desktop and copy the files using SCP.
An example solution.
Import the attached dar file WFA3_0_sinhaa__Workflow_to_upload_files_from_your_desktop_to_WFA_server_and_print__the_contents_.dar
The workflow is : Workflow to upload files from your desktop to WFA server and print the contents. This workflow has 2 commands.
- Upload a file to WFA server
- Display contents of files in a given Directory
So my simple task is to print the contents of a file which I need to upload from my desktop using WFA by providing the file path as Input to the workflow during execution.
The credentials are only known to the workflow executor who provides during workflow execution. And since the SSH server is running on his deskop, he can control/restrict the incoming requests as he desires. So this is fairly secure and configurable.
Alternate Solution for Windows Desktops
If your requirement is only the contents of the file and not the file itself, then this can be done by enabling PS Remoting on your WFA and your windows desktop. See the attached doc Windows_desktop_file_contents_as_input.docx . Also attaching a sample workflow dar WFA3_0P2_Workflow_to_Input_content_of_a_desktop_file_to_WFA_sinhaa.dar.
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.