Skip to main content
1-Visitor
Jul 14, 2023 4:28 PM UTC
Solved

Download external file using TWX service

Hello All,

 

I wanted to download external file in twx repository using service 

so basically i need code snippet to download this file in TWX Service using link and save to repo

 

Any help appreciated ! 

 

 

nmutterAnswer
17-Peridot
Jul 15, 2023 11:45 AM UTC

The Resource ContentLoaderFunctions does offer services like LoadBinary, LoadImage, ...

There are some examples here: https://community.ptc.com/t5/IoT-Tips/ContentLoaderFunctions-in-ThingWorx/ta-p/820230

2 replies

nmutter17-PeridotAnswer
17-Peridot
Jul 15, 2023 11:45 AM UTC

The Resource ContentLoaderFunctions does offer services like LoadBinary, LoadImage, ...

There are some examples here: https://community.ptc.com/t5/IoT-Tips/ContentLoaderFunctions-in-ThingWorx/ta-p/820230

Translate
1-Visitor
Jul 17, 2023 8:33 AM UTC

I found below solution working for me

 

// remoteFileUrl : link for file to be download

// MyFileRepository : Repo name

 

// result: BLOB
var result =  Resources["ContentLoaderFunctions"].LoadBinary({
ignoreSSLErrors: true /* BOOLEAN */,
url: remoteFileUrl /* STRING */,
});
 
 Things["MyFileRepository"].SaveBinary({
path: 'File1.docx' /* STRING */,
content: result /* BLOB */
});
Translate