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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Event listener for ExtractArchive

Willie
16-Pearl

Event listener for ExtractArchive

My understanding is that Things[fileRepositoryThing].ExtractArchive(params) is an asynchronous function.  Is there an event listener service similar to addEventListener( ) that I can use to run a callback function when the extraction is complete?

 

I am moving the file after it's extracted, but I want to make the process more efficient by using some kind of event listener instead of a do while loop.

 

	let moveFileComplete = false;
	do {
		try {
			Things["SystemRepository"].MoveFile({
				targetPath: "/Push/" + me.name + "/" + fileName /* STRING */ ,
				overwrite: true /* BOOLEAN */ ,
				sourcePath: "/temp/Push/" + fileName /* STRING */
			});
			moveFileComplete = true;
		} catch (err) {
			moveFileComplete = false;
			pause(29999); //pause to ensure file extraction is complete before restarting loop
		}
	} while (!moveFileComplete);

 

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/things/repository/FileRepositoryThing.html#ExtractArchive(java.lang.String,java.lang.String,java.lang.String)

 

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Willie ,

The ExtractArchive method is not asynchronous (at least in 9.3.4). Can you please let me know where you have observed this statement in our documentation? We need to correct this.

I've just extracted a 3,4GB file and the method was correctly blocking as expected until it finished extraction.

View solution in original post

2 REPLIES 2

Hi @Willie ,

The ExtractArchive method is not asynchronous (at least in 9.3.4). Can you please let me know where you have observed this statement in our documentation? We need to correct this.

I've just extracted a 3,4GB file and the method was correctly blocking as expected until it finished extraction.

Hi @VladimirRosu ,

 

Thank you for the clarification.  I did not see it in a document, but assumed it since I was getting an error with Things["SystemRepository"].MoveFile.

The error I was getting is the following:

************************************************************************************************************

java.lang.Exception: fromFile does not exist [file: /temp/....someFileName]

************************************************************************************************************

 

It seems that when I fixed an issue related to the fileName located in a code block above the line for MoveFile service, it corrected the "fromFile does not exist" issue, 

			Things["SystemRepository"].MoveFile({
				targetPath: "/Push/" + me.name + "/" + fileName /* STRING */ ,
				overwrite: true /* BOOLEAN */ ,
				sourcePath: "/temp/Push/" + fileName /* STRING */
			});

 

I thought the work around with the do-while loop had fixed the issue, since I added the do-while loop when I fixed the other issue related to the fileName.  It's working without the do-while loop now.

Top Tags