You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

360boy

Intermediate

  • "360boy" started this thread

Posts: 221

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

1

Thursday, February 22nd 2018, 6:20pm

Verify file existance with KRPANO

Hello there,

I've been wondering recently how to check if a file exist on folder through building dynamically it's URL and then checking with some Krpano command. Jordi Valverdú published recently a plugin for this but I need to customize this functionality some more.

Any ideas? Klaus?

Best *thumbup*

Luis

2

Friday, February 23rd 2018, 12:34am

the published example probably works by sending a http header request..
the downside is that you must wait for an answer of the server..
to be fail safe that would need a timeout, too.
dunno if the plugin has all of that...

360boy

Intermediate

  • "360boy" started this thread

Posts: 221

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

3

Friday, February 23rd 2018, 5:22pm

Hi indexofrefraction, I don't know either as it's encrypted. I just wonder as there's a report at console each time a file wasn't found, so I guess that parameter is already available internally in krpano but don't know if it's possible to access to it. I also wonder if there's some way to know if a file is already loaded, as currently I'm working with the onloaded event on an image layer, but that one seems to be triggered just once on first load. Any ideas here?

Thanks!

Alexey Tkachenko

Professional

Posts: 736

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

4

Monday, February 26th 2018, 8:02am

Hi)

Try this action in some test standard Krpano tour.

Source code

1
<action name="verify_file" >		set(events[test].onloaderror, showlog();trace('OOPS! NO FILE FOUND!'););		addlayer(test);		set(layer[test].url, 'skin/test.png');		set(layer[test].onloaded, trace(FILE WAS RELOADED!););		delayedcall(3, set(layer[test].url, 'skin/vtourskin_hotspot.png');); 		delayedcall(6, set(layer[test].url, 'skin/rotate_device.png');); 	</action>



It seems it maybe the way to go or adapt it further.
Regards,

Alexey

360boy

Intermediate

  • "360boy" started this thread

Posts: 221

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

5

Monday, February 26th 2018, 3:46pm

Hello Alexey,

Haven't really used "onloaderror" before, interesting idea. In my case what I want to do is to configure krpano to auto build image galleries, counting images on server for each. I don't necessarily want to load all those at once which is what your action is doing, still is an interesting turnaround so I'll check it out.

Anybody else has an idea to check specifically if some image exists on server by its URL? also, any way to check if a URL image was already loaded in cache?


Thanks!

Alexey Tkachenko

Professional

Posts: 736

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

6

Monday, February 26th 2018, 3:49pm

Check out this thread https://krpano.com/forum/wbb/index.php?p…+file#post61365

It seems you'll need some server-side solution (php?)

OMG))) this is my 666th post here))) LOL *w00t*
Regards,

Alexey

7

Monday, February 26th 2018, 4:00pm

check this out....
https://stackoverflow.com/questions/3646…pure-javascript

but in your case, you could add a small php on your server to check if the file exists
then on the client side you can do a request like yourserver.com/checkfile.php?name=image.jpg

8

Monday, February 26th 2018, 4:01pm


OMG))) this is my 666th post here))) LOL *w00t*


scary!!! *squint*

jordi

Intermediate

Posts: 427

Location: Barcelona

Occupation: creating ideas & coding them

  • Send private message

9

Tuesday, February 27th 2018, 4:53pm

but in your case, you could add a small php on your server to check if the file exists
then on the client side you can do a request like yourserver.com/checkfile.php?name=image.jpg


you do not need php for that, with my plugin you can probe if the file exist or not.

check out here

there's a variable called urlExist is set to 0 or 1.

What Luis is trying to do is different, he wants to get an array of files from a specific folder, that could be done with my plugin right now, only if you would follow a specific naming, let's say if you name all your images in those folder img_1.jpg, img_2.jpg, img_n.jpg, then you can easily do a for that check if those images exist

Source code

1
2
3
4
5
6
7
8
9
10
for(set(i,0), i LT maxNumofImg, inc(i), 
	checkFileExist(calc('path/to/your/folder/img_' + i + '.jpg'));
	if(urlExist, 
		addlayer(...)
		,
		// if no holes in numeration   		
		warning('no more images');    		
		break();
	);
);


** untested code



Simple enough, of course you can go to more accurate & flexible, if you would need that PM, I have already implemented that.
everpano.com smart virtual tours

360boy

Intermediate

  • "360boy" started this thread

Posts: 221

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

10

Wednesday, February 28th 2018, 10:08pm

Hello everyone, thanks for your help, I'm expecting to do this internally in krpano but will keep PHP solution as a second option inexofrefraction.


What Luis is trying to do is different, he wants to get an array of files from a specific folder, that could be done with my plugin right now, only if you would follow a specific naming, let's say if you name all your images in those folder img_1.jpg, img_2.jpg, img_n.jpg, then you can easily do a for that check if those images exist

Source code

for(set(i,0), i LT maxNumofImg, inc(i),
checkFileExist(calc('path/to/your/folder/img_' + i + '.jpg'));
if(urlExist,
addlayer(...)
,
// if no holes in numeration
warning('no more images');
break();
);
);
This is the idea Jordi, I've used some similar code for this functionality with your plugin but had some issues aat online implementation, will PM to check those with you. Thank you!

OMG))) this is my 666th post here))) LOL
LOL! *evil*