GCS configuration in spring boot - Neethahiremath/Wiki GitHub Wiki
add the gcs configurations in yml file
gcs:
bucket:
projectId: projectId
bucketName: name
secretkeyPath: ""
filePath: path of files
fileName: file name
feedFileHeader: "A|B|C|D"
filetype:filetype
read the properties as class
use this property in new class and on post construct
class GCSConfig{
private GCSProperty property;
private GoogleCredentials googleCredentials;
@PostConstruct
public void init() throws IOException {
try (InputStream serviceAccountStream = new FileSystemResource(property.getSecretkeyPath).getInputStream()) {
googleCredentials = ServiceAccountCredentials.fromStream(serviceAccountStream);
} catch (IOException ex) {
throw ex;
}
}
}