/** * Read the content of a file * * @param containerName Name of the folder * @param objectName name of the file * @return Content of the files */ public byte[] readObject(String containerName, String objectName) { HttpURLConnection urlConnection = new ConnBuilder(credentials, containerName, objectName).getConnection(); Response response = doReadOperation(urlConnection); if (!response.isSuccessCode()) { if (response.isAuthDenied()) { log.warn("Refreshing credentials and retrying"); authenticate(); return readObject(containerName, objectName); } else { log.error(Util.getMessage("ErrorReadingObject") + objectName + " from container " + containerName + ", code = " + response.code); } } return response.payload; }
/** * List files in a folder * * @param containerName Folder name * @return List of file names */ public List<String> listObjects(String containerName) { HttpURLConnection urlConnection = new ConnBuilder(credentials, containerName, null).getConnection(); Response response = doReadOperation(urlConnection); if (!response.isSuccessCode()) { if (response.isAuthDenied()) { log.warn("Refreshing credentials and retrying"); authenticate(); return listObjects(containerName); } else { log.error(Util.getMessage("ErrorListingContainer") + containerName + ", code = " + response.code); } } return response.payloadAsLines(); }
/** * Read the content of a file * * @param containerName Name of the folder * @param objectName name of the file * @return Content of the files */ public byte[] readObject(String containerName, String objectName) { HttpURLConnection urlConnection = new ConnBuilder(credentials, containerName, objectName).getConnection(); Response response = doReadOperation(urlConnection); if (!response.isSuccessCode()) { if (response.isAuthDenied()) { log.warn("Refreshing credentials and retrying"); authenticate(); return readObject(containerName, objectName); } else { log.error(Util.getMessage("ErrorReadingObject") + objectName + " from container " + containerName + ", code = " + response.code); } } return response.payload; }
/** * List files in a folder * * @param containerName Folder name * @return List of file names */ public List<String> listObjects(String containerName) { HttpURLConnection urlConnection = new ConnBuilder(credentials, containerName, null).getConnection(); Response response = doReadOperation(urlConnection); if (!response.isSuccessCode()) { if (response.isAuthDenied()) { log.warn("Refreshing credentials and retrying"); authenticate(); return listObjects(containerName); } else { log.error(Util.getMessage("ErrorListingContainer") + containerName + ", code = " + response.code); } } return response.payloadAsLines(); }