File Transfers - configuration and parameters
From Mike Mahoney's blog:
"There’s a few pieces you need in place to do a file transfer. Transfers can be executed in either direction: edge->platform or platform->edge. To do a transfer the edge component must be configured with a set of virtual directories. For the EMS, the configuration section would look like this:
"file": {"virtual_dirs":[
{ “In" : "./in" }, { “Out": "./out" }, { "staging": "./staging" }],
"staging_dir": “staging"
}
This is important because you will need to virtual dir names in the parameters to the Copy call. In the above example assumes that there are three directories in the same location as the EMS executable: ‘in’, ‘out’, ‘staging’. You can specify absolute paths as well.
For the example I’m about to give, assumer the following:
- A RemoteThingWithFileTransfer named RT1.
- That the files are being transferred to/from the SystemRepository thing.
- That the EMS is installed in C:\Microserver and that C:\Microserver\in, C:\Microserver\out, and C:\Microserver\staging exist.
- The source file is located in the ‘files’ directory of the SystemRepository
In this case, the Copy parameters, for a transfer from the Platform to the Edge would be:
- sourceRepo: SystemRepository // Name of the Thing to transfer from
- targetRepo: RT1 // Name of the Thing to transfer to
- sourcePath: /files // Directory in the SystemRepository
- targetPath: /In // The name of a virtual dir. In this case it is pointing to C:\Microserver\in. You can also specify subdirs.
- sourceFile: abc.json
- targetFile: abc.json // Optional. The default is the sourceFile name. You can rename files during the transfer
Note that the Things must be instances of one of the following templates: FileRepository, RemoteThingWithFileTransfer, RemoteThingWithFileTransferAndTunneling.
Also, as of 5.0+ you don’t need the Lua script resource to do file transfers. You can add an auto_bind entry to your config.json to specify the name of a Thing that will participate in file transfers:
"auto_bind”: [
{ “name”: “RT1” }]
"
