Thingworx File Transfer JDK -> Thingworx: Unable to create File
Hi,
I'm trying to do a File transfer via Java SDK from my Client to the Thingworx Storage (on Thingworx Server). Herefore I created the following Code using the CopyService:
public static void main(String[] args) {
ClientConfigurator config = new ClientConfigurator();
String uri = "http://xxx.xx.xx.xx:8080/Thingworx/WS";
config.setUri(uri);
config.setAppKey("xxxxx");
config.ignoreSSLErrors(true);try {
ConnectedThingClient client = new ConnectedThingClient(config);FileTransferVirtualThing myThing = new FileTransferVirtualThing("RT1", "File Transfer Example", client);
myThing.addVirtualDirectory("in", "C:\\tmp\\in");
myThing.addVirtualDirectory("out", "C:\\tmp\\out");client.bindThing(myThing);
client.start();ValueCollection parameters = new ValueCollection();
parameters.setValue("sourceRepo", new StringPrimitive("RT1"));
parameters.setValue("sourcePath", new StringPrimitive("/out"));
parameters.setValue("sourceFile", new StringPrimitive("a.txt"));
parameters.setValue("targetRepo", new StringPrimitive("SystemRepository"));
parameters.setValue("targetPath", new StringPrimitive("/files"));
parameters.setValue("targetFile", new StringPrimitive("a.txt"));
parameters.setValue("async", new BooleanPrimitive(false));client.invokeService(ThingworxEntityTypes.Subsystems, "FileTransferSubsystem", "Copy", parameters, 120);
client.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
The file is not transferred, the error message in the output is the following:
23:58:21.149 [NettyClient-NIO-1] DEBUG c.t.c.c.e.DispatchingClientEndpoint - API REQUEST received [endpoint id: 0] APIRequestMessage [requestId: 2206, endpointId: -1, sessionId: -1, method: POST, entityName: RT1, characteristic: Unknown, target: ]
23:58:21.150 [ClientProcessor-3] WARN c.t.c.c.t.f.FileTransferVirtualThing - File transfer has been canceled. tid: , reason: Unable to Create File [/files/a.txt.SystemRepository.part]
How to deal with this error? Seems like the RT1 Thingworx Thing can't write to this path? What can I do to allow it to write here?
Maybe important to know: Vice versa its working, I can transfer files from /files SystemRepository to my client directory (here I'm getting a Timeout Exception but the File is at least transferred...)
Many thanks in advance!

