Skip to main content
1-Visitor
July 14, 2023
Solved

Download external file using TWX service

  • July 14, 2023
  • 2 replies
  • 2775 views

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 ! 

 

 

Best answer by nmutter

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

nmutter16-PearlAnswer
16-Pearl
July 15, 2023

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

1-Visitor
July 17, 2023

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 */
});