
com.aol.micro.server.s3.DirectoryCleaner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro-s3 Show documentation
Show all versions of micro-s3 Show documentation
Opinionated rest microservices
package com.aol.micro.server.s3;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class DirectoryCleaner {
private final String temporaryDirectory;
@Autowired
public DirectoryCleaner(@Value("${s3.temp.dir:#{null}") String temporaryDirectory) {
this.temporaryDirectory = temporaryDirectory;
}
@PostConstruct
public void clean() throws IOException {
if (temporaryDirectory != null && new File(temporaryDirectory).exists()) {
Path directory = FileSystems.getDefault().getPath(temporaryDirectory);
Files.walkFileTree(directory, new CleanupFileVisitor(directory));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy