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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

How to get file from ThingWorx repository to Vuforia

Jamal8548
12-Amethyst

How to get file from ThingWorx repository to Vuforia

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!

5 REPLIES 5
TonyZhang
13-Aquamarine
(To:Jamal8548)

Hi @Jamal8548,

 

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);

 

 

@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.

TonyZhang
13-Aquamarine
(To:Jamal8548)

Hi @Jamal8548 ,

 

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.

Thanks i will try and give here remarks but LoadImage function is also doing the same thing for the image file to get the Blob data of the image. Do you want to say something about it? and yes for other type of files like pdf we can use the LoadBinary with contentLoaderFunction as you suggested. 

TonyZhang
13-Aquamarine
(To:Jamal8548)

Hi @Jamal8548,

 

Are you talking about the difference between LoadImage and LoadBinary?

To me, they seem to be calling the same underlying function to get the Blob (binary) data of a file (no difference apart from name).

You may be able to use this interchangbly (use LoadImage to get a pdf file content or use LoadBinary to get an image content if you like but better to test it out to double confirm).

I guess using LoadImage function has one advantage - you can tell what this code is doing by its name (getting an image file!)

Top Tags