Using the .NET SDK, I created a class based on FileTransferVirtualThing and had difficulty getting the GetFile() method to work without failure. I was invoking GetFile() inside a Service accessed as part of a Thing in ThingWorx Composer. The Thing was bound via the Identity provided by the .NET SDK. The service in the virtual thing performed the following operation:
[method: ThingworxServiceDefinition(name = "TestFileDownload", description = "Attempt to use GetFile")[return: ThingworxServiceResult(name = CommonPropertyNames.PROP_RESULT, description = "", baseType = "NOTHING")]
After looking at the logs generated during the file transfer attempt, I saw the following:
[Verbose] getRealPath: Real path for *SDKThing:__staging__/*SDKThingstaged.bar.ps1.part\ = \opt\thingworx\tw_staging\*SDKThingstaged.bar.ps1.part [Error] twFileManager_OpenFile: Opening file. Error: 123
Error 123 is a byproduct of an invalid filename or path. The asterisk in the filename appears to be the problem. To be clear, the Identity supplied to the constructor was 'SDKThing' without the asterisk(*). The SDK added the asterisk.
However, changing the class to use the alternate FileTransferVirtualThing constructor that omits the identity results in a successful transfer. When the Thing in ThingWorx Composer is bound to the name rather than the identity, the filename used is valid:
[Verbose] getRealPath: Real path for SDKThing:__staging__/SDKThingstaged.bar.ps1.part\ = \opt\thingworx\tw_staging\SDKThingstaged.bar.ps1.part
Is there a known issue with file transfers with Things bound via their Identity? This seems like a bug in the SDK or its a configuration mistake on my part that wasn't readily obvious. For added perspective, SendFile() worked fine when its Thing in ThingWorx Composer was bound via Identity.