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

How to get notified when a file transfer is complete

SOLVED
Highlighted
Level 8

How to get notified when a file transfer is complete

Hi,

does anyone know how I can hook into a file transfer job complete event. I have a mash up which can kick start a file transfer from the edge to a file repository thing. Is there a way that I can hook into a notification that the transfer was completed successfully?

I am using the  FileTransferSubsystem Copy service to do the actual transfer. I can see that one of the parameters for the service is ​async​ which is currently set to false.

async - Should the service wait for the copy to complete - BOOLEAN


I would prefer not to wait for the transfer complete in the service if possible as files might be quite large.

I notice that the copy service returns a result  - INFOTABLE - Aspects {dataShape:FileTransferJob} . Is there some way I can use this. I thought maybe I could use the transferId​ parameter and a timer to check if the job was done by using FileTransferSubsystem IsTransferJobActive ​service? Likewise it would also be good to know if it failed.

Thanks,

K

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to get notified when a file transfer is complete

On the file repository thing, there is an event called FileTransfer. You just need to subscribe to this, and then there are different statuses which will be returned into the subscription, e.g. "VALIDATED" if it completed successfully, "ERROR" if it did not complete, or "ACTIVE" if the file transfer is started and ongoing. There is a similar approach which checks other event data instead of status in KCS here. Hope this helps!

12 REPLIES 12

Re: How to get notified when a file transfer is complete

On the file repository thing, there is an event called FileTransfer. You just need to subscribe to this, and then there are different statuses which will be returned into the subscription, e.g. "VALIDATED" if it completed successfully, "ERROR" if it did not complete, or "ACTIVE" if the file transfer is started and ongoing. There is a similar approach which checks other event data instead of status in KCS here. Hope this helps!

Re: How to get notified when a file transfer is complete

Hi Tori,

thanks for that, extremely helpful. I can see how I can get the file repository to subscribe to the events now. I do have one further question, do you have any idea how can get my mashup to respond to a 'file transfer complete' event? The only way I can think of, is to poll the file repository on a timer but ideally I'd like to respond to the event directly rather than have to keep polling. Is there any way at all to get a mashup to subscribe to events?

K

Re: How to get notified when a file transfer is complete

I am a bit confused; what exactly do you want the mashup to do with the event information?

Re: How to get notified when a file transfer is complete

Hi Kieron,

The only way to get a Mashup notified (push rather than poll) by a server side "event change" it's through property update changes . Then, for instance, you will have to add a property on the FileRepository, let's call it nUploads as INTEGER, and on the event that you subscribed before just add up +1 to the nUploads property, then from the mashup you can push "subscribe" to this nUploads property in order to refresh the Mashup.

Best Regards,

Carles.

Re: How to get notified when a file transfer is complete

Sorry, didn't explain myself very well.

In my mash up I kick off a process on the edge device which results in a file being created then uploaded to the server. Due to the time this might take (c.30 seconds) I don't want to wait for the process to complete.

What I would like to achieve is to subscribe to the file transfer event so that I can have a status message appear in my mash up when the file transfer is complete.

hope that is a bit clearer?

K

Re: How to get notified when a file transfer is complete

Hi Carles,

thanks for the help. Not sure what you mean by 'push subscribe'. do you mean using a timer to poll the 'nUploads' parameter, or is there a way in a mash up to subscribe to this property's data change event?

K

Re: How to get notified when a file transfer is complete

Hi Kieron, yes there's a method to "subscribe to property's data change event" please follow the link referenced on my previous post

Re: How to get notified when a file transfer is complete

Hey Kieron, I think what Carles is describing involves the GetProperties service in newer versions of ThingWorx. All you have to do is check the box called "Automatically update..." which appears in the right-hand data pane when the service is selected, and then bind the property to the display field, whatever is used. When the FileTransfer Event occurs, in the subscription, update this property, and you are good to go.

Re: How to get notified when a file transfer is complete

Thanks Carles, as usual you have been very helpful.

K