cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Thingworx File Transfer JDK -> Thingworx: Unable to create File

Highlighted
Newbie

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!

2 REPLIES 2
Highlighted

Re: Thingworx File Transfer JDK -> Thingworx: Unable to create File

Are you sure the App Key you are using to connect to the Platform has permission to modify and call services on the file repository?

Re: Thingworx File Transfer JDK -> Thingworx: Unable to create File

Just found out the Thingworx Installation had no right to write to the specified Reposity Path. Fixed this privileges issue, now the File gets transferred.

BUT for each File Transfer a "Timed Out Api Request Message" gets thrown (but the file gets transferred). Anyone has an idea how to fix this?

// Should I outsource this question to separate Thread?

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!