백엔드
Spring Boot에서 gcp storage 사용 시 storage에 의존성 주입이 되지 않은 경우
gi2
2023. 7. 26. 18:40
@Configuration
public class GoogleCloudStorageConfig {
@Bean
public Storage storage() throws IOException {
ClassPathResource resource = new ClassPathResource("key.json");
GoogleCredentials credentials = GoogleCredentials.fromStream(resource.getInputStream());
String projectId = "project id";
return StorageOptions.newBuilder()
.setProjectId(projectId)
.setCredentials(credentials)
.build()
.getService();
}
}
위와 같은 Configuration 파일을 만들어 storage 의존성을 직접 주입해준다........