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

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

PDF file transfer with FileTransferSubsystem

Yoshihiko.N
14-Alexandrite

PDF file transfer with FileTransferSubsystem

Hi Developers,

I'm trying to transfer pdf files between repositories. 
the method I'm using is in the below. 

I can transfer xml files with the following method but cannot transfer pdf files.
it seems that all binary files cannot be transferred with the following method.

if so, how can we transfer binary files ?

 

our thingworx version is ThingWorx 9.2.6-b366 - 

 

 

var target_repo = me.name;
var target_path = "/in";
var target_filename=filename;
var params = {
async: false /* BOOLEAN */,
sourceRepo: repo /* STRING */,
targetRepo: target_repo/* STRING */,
targetFile: target_filename /* STRING */,
targetPath:target_path /* STRING */,
sourceFile: target_filename /* STRING */,
sourcePath: path /* STRING */,
timeout: 60 /* INTEGER */
};

result = Subsystems["FileTransferSubsystem"].Copy(params);


Thanks and Regards,

 

7 REPLIES 7

Hi @Yoshihiko.N ,

 

What do you mean when saying "you cannot transfer PDF files" ? Please share as much context as you can (defining what I asked, are there logs in any of the ThingWorx logs, have you tried with other binary file types?)

 

Thx

Hi Vlad,

Thank you for your reply and sorry for my few information.

let me give you in more details.

1.  we modified FileTransferExample for our environment, and execute the jar file on the target virtual machine.

open jdk 19 is running on the target vm.

YoshihikoN_0-1671663561972.png

2. we can send ascii file such as bat/xml/txt with the method of Subsystems["FileTransferSubsystem"].Copy(params).

however we couldnt send binary files such as xlsx/docx/pdf with the same method.
when we tried to send binary files with Subsystems["FileTransferSubsystem"].Copy(params), the jar file on the target vm was stopped.
I tried to see the error message on the command prompt but the prompt was closed in a few seconds after the error.

 

 

 

 

Yoshihiko.N
14-Alexandrite
(To:Yoshihiko.N)

Hi Developers,

Thank you for your strong support in always.

the above my questions is still not solved.

I'd be happy if you provide me ways to solve.

Thanks and Regards.

jensc
17-Peridot
(To:Yoshihiko.N)

Hello @Yoshihiko.N,

 

I managed to do this using the same subsystem function:

 

 

 

let result = Subsystems["FileTransferSubsystem"].Copy({
	async: undefined /* BOOLEAN */ ,
	sourceRepo: 'YourSourceRepository' /* STRING */ ,
	metadata: undefined /* JSON */ ,
	targetRepo: 'YourTargetRepository' /* STRING */ ,
	targetFile: 'PDFFile.pdf' /* STRING */ ,
	targetPath: '/' /* STRING */ ,
	queueable: undefined /* BOOLEAN */ ,
	sourceFile: 'PDFFile.pdf' /* STRING */ ,
	sourcePath: '/' /* STRING */ ,
	timeout: undefined /* INTEGER */
});

 

 

I am running this on a 9.1.12 platform, but I assume it should work on any platform that has this function.

 

The "targetPath" and "sourcePath" is the path in your repositories, so the "/" is the first "level" and if you have the file in a folder just put "/YourFolder".

 

Hope this helps you.

 

Thanks,

Jens

Yoshihiko.N
14-Alexandrite
(To:jensc)

Hi Jen,

Thank you for your reply.
I've tried but failed.

 

here the below is the error code output from the command prompt.
I'd be happy if you can find root cause and provide ways of solve.

 

============================================================


13:45:46.357 [NettyClient-NIO-1] ERROR com.thingworx.communications.client.connection.netty.ThingworxClientConnectionHandler - WebSocket exception caught!, closing connection!
io.netty.handler.codec.DecoderException: io.netty.handler.codec.CodecException: cannot read uncompressed buffer
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1336)
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1127)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1162)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:545)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: io.netty.handler.codec.CodecException: cannot read uncompressed buffer
at io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder.decode(DeflateDecoder.java:89)
at io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateDecoder.decode(PerMessageDeflateDecoder.java:64)
at io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateDecoder.decode(PerMessageDeflateDecoder.java:30)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
... 28 common frames omitted
13:45:46.357 [NettyClient-NIO-1] INFO com.thingworx.communications.client.connection.netty.NettyClientConnection - [websocket id: 0-0] Websocket close received
13:45:46.357 [NettyClient-NIO-1] INFO com.thingworx.communications.client.connection.netty.NettyClientConnection - [websocket id: 0-0] Closing underlying websocket channel
13:45:46.372 [NettyClient-NIO-1] INFO com.thingworx.communications.client.connection.netty.NettyClientConnection - [websocket id: 0-0] Unregistering NettyClientConnection from ClientEndpoint
13:45:46.372 [NettyClient-NIO-1] DEBUG com.thingworx.communications.common.endpoints.CommunicationEndpoint - [Endpoint id: 0, connection id: 0-0] removed Connection
13:45:46.372 [NettyClient-NIO-1] INFO com.thingworx.communications.common.endpoints.CommunicationEndpoint - All Connections are closed [endpoint id: 0]
13:45:46.372 [NettyClient-NIO-1] INFO com.thingworx.communications.client.ConnectedThingClient - Communications Endpoint Closed
13:45:46.372 [NettyClient-NIO-1] INFO com.thingworx.communications.client.connection.netty.NettyClientConnection - [websocket id: {}] Websocket close successful? Open: false Active: false
13:45:47.328 [Client-EndpointMonitor-1] DEBUG com.thingworx.communications.common.endpoints.monitor.ConnectivityMonitorTask - Entering duty cycle ON
13:45:47.328 [Client-EndpointMonitor-1] INFO com.thingworx.communications.common.endpoints.monitor.ConnectivityMonitorTask - Endpoint not connected [name: EP_0, id: 0]. Attempting [re]connect in 60 seconds...

 

============================================================

 

Thanks and Regards,

jensc
17-Peridot
(To:Yoshihiko.N)

Hello,

 

If you have made changes to this subsystem function then I can't really help you.

But with this error log provided there might be someone who has some ideas.

Best of luck to you!

 

Thanks,

Jens

slangley
23-Emerald II
(To:Yoshihiko.N)

Hi @Yoshihiko.N

 

Some ideas:

 

  1. Is there adequate space on the target system?
  2. How large are the binary files?  Have you checked to make sure you're not exceeding file size?
  3. Is it possible certain file types are blocked on the target system?

 

This page from the Help Center may help.

 

Regards.

 

--Sharon

Announcements


Top Tags