Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

360boy

Fortgeschrittener

  • »360boy« ist der Autor dieses Themas

Beiträge: 249

Wohnort: Mexico City

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

  • Nachricht senden

1

Donnerstag, 22. Februar 2018, 18:20

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

Freitag, 23. Februar 2018, 00:34

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

Fortgeschrittener

  • »360boy« ist der Autor dieses Themas

Beiträge: 249

Wohnort: Mexico City

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

  • Nachricht senden

3

Freitag, 23. Februar 2018, 17:22

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!

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

4

Montag, 26. Februar 2018, 08:02

Hi)

Try this action in some test standard Krpano tour.

Quellcode

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

Fortgeschrittener

  • »360boy« ist der Autor dieses Themas

Beiträge: 249

Wohnort: Mexico City

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

  • Nachricht senden

5

Montag, 26. Februar 2018, 15:46

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!

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

6

Montag, 26. Februar 2018, 15:49

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

Montag, 26. Februar 2018, 16:00

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

jordi

Profi

Beiträge: 583

Wohnort: Barcelona

Beruf: creating ideas & coding them

  • Nachricht senden

9

Dienstag, 27. Februar 2018, 16:53

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

Quellcode

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 step beyond 360

360boy

Fortgeschrittener

  • »360boy« ist der Autor dieses Themas

Beiträge: 249

Wohnort: Mexico City

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

  • Nachricht senden

10

Mittwoch, 28. Februar 2018, 22:08

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*