Skip to content

Commit

Permalink
Merge pull request #93 from BbeumbungE/hotfix/BACK-342
Browse files Browse the repository at this point in the history
hotfix: GOOGLE CREDENTIAL 오류 수정 [BACK-342]
  • Loading branch information
ah9mon authored Oct 5, 2023
2 parents 3974ff0 + fe013fa commit f5d59c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

rich-suprstate-386908-7630a2d1a95f.json
### STS ###
.apt_generated
.classpath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.stereotype.Service;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
Expand All @@ -19,8 +20,8 @@
@Slf4j
public class GoogleVisionApiService {

@Value("${google.service.account.key}")
private String serviceAccountKey;
@Value("${GOOGLE_APPLICATION_CREDENTIALS}")
private String serviceAccountKeyPath;

public Map<String, Float> detectLabels(String filePath) {
List<AnnotateImageRequest> requests = new ArrayList<>();
Expand All @@ -39,9 +40,8 @@ public Map<String, Float> detectLabels(String filePath) {
.build();
requests.add(request);

GoogleCredentials credentials = GoogleCredentials.fromStream(
new ByteArrayInputStream(serviceAccountKey.getBytes(StandardCharsets.UTF_8))
);
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(serviceAccountKeyPath));

ImageAnnotatorSettings settings = ImageAnnotatorSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build();
Expand Down

0 comments on commit f5d59c1

Please sign in to comment.