Highlighted
Frequent Contributor.
Frequent Contributor.
306 views

Check File Existence without downloading the File

Jump to solution

Hi 

I've a lot of "URL" that points to differnt files in my server.

I want to check if the file is availalbe in the given URL without downloading the actual file.

Since files can be of any size, I just want to test there existence alone.

Is there any functions or workarounds? 

 

Thanks,

Anand

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Hi

This can easily be done by only checking for the header of the file, is standard HTTP protocol.

	web_custom_request("CheckIfExists",
	                  "URL=https://www.wikipedia.org/",
	                  "Method=GET",
	                 LAST);

	web_custom_request("CheckIfExists_head",
	                  "URL=https://www.wikipedia.org/",
	                  "Method=HEAD",
	                 LAST);

	web_custom_request("CheckIfExists_404",
	                  "URL=https://www.wikipedia.org/404.html",
	                  "Method=GET",
	                 LAST);

Try executing the examples above.

The first one does a normal "GET", the second, only fetches the header and the last do not exist, and gives a 404.

br /ola


Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

.

View solution in original post

Tags (1)
1 Reply
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Hi

This can easily be done by only checking for the header of the file, is standard HTTP protocol.

	web_custom_request("CheckIfExists",
	                  "URL=https://www.wikipedia.org/",
	                  "Method=GET",
	                 LAST);

	web_custom_request("CheckIfExists_head",
	                  "URL=https://www.wikipedia.org/",
	                  "Method=HEAD",
	                 LAST);

	web_custom_request("CheckIfExists_404",
	                  "URL=https://www.wikipedia.org/404.html",
	                  "Method=GET",
	                 LAST);

Try executing the examples above.

The first one does a normal "GET", the second, only fetches the header and the last do not exist, and gives a 404.

br /ola


Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

.

View solution in original post

Tags (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.