@Test @Tag("S3Test") public void testListFilesInFolderAndRead() { Resource[] files = handler.listFilesInFolder(BUCKET_NAME, "_unittest/forListFiles", "*"); Arrays.stream(files).filter(r -> r.getFilename().equals("_unittest/forListFiles/dummyfile.txt")) .forEach(r -> { try (var br = new BufferedReader(new InputStreamReader(r.getInputStream(), StandardCharsets.UTF_8))) { assertThat(br.readLine()).isEqualTo("dummy"); } catch (IOException e) { throw new RuntimeException(e); } }); }
public Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern) { var s3FolderUrl = "s3: var searchPath = s3FolderUrl + "/" + filePattern; try { return resolver.getResources(searchPath); } catch (IOException e) { throw new RuntimeException(e); } }
S3FileHandler { public Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern) { var s3FolderUrl = "s3: var searchPath = s3FolderUrl + "/" + filePattern; try { return resolver.getResources(searchPath); } catch (IOException e) { throw new RuntimeException(e); } } }
S3FileHandler { public Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern) { var s3FolderUrl = "s3: var searchPath = s3FolderUrl + "/" + filePattern; try { return resolver.getResources(searchPath); } catch (IOException e) { throw new RuntimeException(e); } } S3FileHandler(AmazonS3 amazonS3, ApplicationContext context); }
S3FileHandler { public Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern) { var s3FolderUrl = "s3: var searchPath = s3FolderUrl + "/" + filePattern; try { return resolver.getResources(searchPath); } catch (IOException e) { throw new RuntimeException(e); } } S3FileHandler(AmazonS3 amazonS3, ApplicationContext context); Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern); void deleteFile(String bucketName, String filePath); void copyFile(String fromBucketName, String fromFilePath, String toBucketName, String toFilePath); Resource moveFileToWorkFolder(String bucketName, String filePath, String folderName, String workFolderSuffix); void deleteAllFilesInFolder(String bucketName, String folderPath); void deleteAllFilesInFolderExcept(String bucketName, String folderPath, List<String> excludeList); }
S3FileHandler { public Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern) { var s3FolderUrl = "s3: var searchPath = s3FolderUrl + "/" + filePattern; try { return resolver.getResources(searchPath); } catch (IOException e) { throw new RuntimeException(e); } } S3FileHandler(AmazonS3 amazonS3, ApplicationContext context); Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern); void deleteFile(String bucketName, String filePath); void copyFile(String fromBucketName, String fromFilePath, String toBucketName, String toFilePath); Resource moveFileToWorkFolder(String bucketName, String filePath, String folderName, String workFolderSuffix); void deleteAllFilesInFolder(String bucketName, String folderPath); void deleteAllFilesInFolderExcept(String bucketName, String folderPath, List<String> excludeList);  }