Hello, we have a large list of file stored in a http server with a database storing the path and file name. Is there a way to iterate for each file in the database and retrieve the http error code (ex. 404)? Thanks,
Hi Read the file path or file name from database, and then iterate each one and fetch it from HTTP serve with tFileFetch, uncheck 'die on error' option if you want the job continue to retrieve next file even there is an error. eg: tMysqlInput--main--tFlowToIterate--iterate--tFileFetch
Thanks,
but I do not want to retrieve the file but to ensure the file is present, as we have many files which are not existing or has been moved to anohter location.
So it is to get the status when the file does not exist anymore at the stored location
cheers.
Ok this is the first time I will use a routine. I have create a new routine call HttpFileCheck. And I paste the code from the link you have provided, is it correct like below? Thanks, package routines; public class HttpFileCheck { import java.net.*; import java.io.*; public static boolean exists(String URLName){ try { HttpURLConnection.setFollowRedirects(false); // note : you may also need // HttpURLConnection.setInstanceFollowRedirects(false) HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection(); con.setRequestMethod("HEAD"); return (con.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (Exception e) { e.printStackTrace(); return false; } } }
Hi I did't test the code, but I think it is OK for you to check the file if it exists. Please test it and let me know if it is OK or any problem you get.