Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi,
is possible to copy file from local drive (D:/Dinesh/abc.zip) to thingworx Repository through FileTransferSubsystem Copy service.
Regards,
Dinesh S
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, assume the following:
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. 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” }
]
Hopefully this helps.
but i need without remote or edge. i have local drive to repository
thanks
Dinesh, just to add to what Polina already mentioned you can also check the FTP Extension from ThingWorx Marketplace for moving files to and fro from the file system
Hi Dinesh,
To add to what Polina and Sushant mentioned, you can also copy files from local drive to thingworx repository as follows:
In the mashup, you can choose a file from local machine and upload it in the ThingWorxStorage--> Repository
for my use case. it should use COPY service in FileTransferSubsystem
The File Transfer Subsystem manages file transfers between Remote Things, File Repositories, and Federated Servers. Like Polina had mentioned , transfers can be executed in either direction: edge->platform or platform->edge. There needs to be some websocket connection to facilitate the file transfer . In your case , to transfer a file from a local drive to a repository the only work around would be to use the file upload widget as mentioned by Yamini.