Skip to main content
16-Pearl
May 31, 2024
Solved

How to get file from ThingWorx repository to Vuforia

  • May 31, 2024
  • 1 reply
  • 1864 views

Hello Dear Community experts,

 

     My question is that i have 6 pdfs in ThingWorx repository each contains 1 page  which i send from Vuforia Studio to ThingWorx and when these 6 pages are generated and sent one by one, then afterwards in the end i need to fetch these 6 pages and merge them and send it to ThingWorx so that 1 pdf will be generated. I am sending file as a blob to save the pdf pages on ThingWorx and now my question is how can i get these pages in front end (Vuforia Studio) again. I know the service getFileListingsWithLinks but there is only downloadlink acutally and i cant see blob in any service.

 

PROCESS: I was doing before that i was generating single pdf after generating each page on client side and send to thingworx but my vuforia app crashes sometimes because its so heavy process even in PC it takes around 35 seconds to generate the pdf and in ipad its around 26seconds but In PC the process never breaks even though it takes long on PC but on Ipad the process takes less time but sometimes its just break the process. Now i am thinking that to generate the pdf for each page and send the pdf one by one to server side so that my memory would be enough on IPAD to handle this process because its one by one and process never breaks. 

 

Any information is welcomed!

Best answer by TonyZhang

Hi @MA8731174,

 

You can use LoadBinary service of ContentLoaderFunctions to get the blob data of PDF in ThingWorx by providing the pdf url to the function.

Here's sample code:

 

let files = Things["YourFileRepository"].GetFileListingWithLinks({
 path: undefined /* STRING */,
 nameMask: undefined /* STRING */
});

let link = files.Find({"name": "FileName.pdf"}).downloadLink;

let params = {
 ignoreSSLErrors: true /* BOOLEAN */,
 url: "<ThingWorx Server URL>" + link /* STRING */,
 password: "AdminPassword" /* STRING */,
 username: "Administrator" /* STRING */
};

// result: BLOB
let result = Resources["ContentLoaderFunctions"].LoadBinary(params);

 

 

1 reply

TonyZhang16-PearlAnswer
16-Pearl
June 14, 2024

Hi @MA8731174,

 

You can use LoadBinary service of ContentLoaderFunctions to get the blob data of PDF in ThingWorx by providing the pdf url to the function.

Here's sample code:

 

let files = Things["YourFileRepository"].GetFileListingWithLinks({
 path: undefined /* STRING */,
 nameMask: undefined /* STRING */
});

let link = files.Find({"name": "FileName.pdf"}).downloadLink;

let params = {
 ignoreSSLErrors: true /* BOOLEAN */,
 url: "<ThingWorx Server URL>" + link /* STRING */,
 password: "AdminPassword" /* STRING */,
 username: "Administrator" /* STRING */
};

// result: BLOB
let result = Resources["ContentLoaderFunctions"].LoadBinary(params);

 

 

MA873117416-PearlAuthor
16-Pearl
July 15, 2024

@TonyZhang Thanks for your reply!

 

 

I am getting this error:-

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

 

 

I am giving username and password of admin and my url is also perfectly fine as if i put the link in google url bar then the file get downloaded so why this error is coming any idea?

One more question: I am just sending an images from thingworx using RESTAPI to another platform. I dont want to send PDFs anymore. please suggest me best solution.

 

I am thinking to use LoadImage


var params = {
path: row.path
};
var blobDataForImage = Things["FileRepository"].LoadImage(params);

 

This function is also giving me blob for the image. What do you think about it as i am now thinking to use this to send image to another platform.

16-Pearl
July 15, 2024

Hi @MA8731174 ,

 

The error indicates your ThingWorx does not trust the certificate of the remote server.

Maybe you can try set ignoreSSLErrors parameter to true when using ContentLoaderFunction to call REST API

Alternatively, you can follow aritcle CS332611 to add the missing certificate to Java truststore.

 

Hope that helps.