Skip to content

Commit

Permalink
Merge pull request #94 from BbeumbungE/dev
Browse files Browse the repository at this point in the history
Hotfix: GOOGLE CREDENTIAL 오류 수정
  • Loading branch information
ah9mon authored Oct 5, 2023
2 parents d9144b8 + f5d59c1 commit 11a514e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/deploy_to_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
touch ./src/main/resources/application.yml
echo "${{ secrets.PROPERTIES_DEV }}" > ./src/main/resources/application.yml
shell: bash

- name: Make key.json
run: |
touch ./src/main/resources/key.json
echo "${{ secrets.VISION_KEY }}" > ./src/main/resources/key.json
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/deploy_to_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ jobs:
touch ./src/main/resources/application.yml
echo "${{ secrets.PROPERTIES_PROD }}" > ./src/main/resources/application.yml
shell: bash


- name: Make key.json
run: |
touch ./src/main/resources/key.json
echo "${{ secrets.VISION_KEY }}" > ./src/main/resources/key.json
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
Expand Down
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 11a514e

Please sign in to comment.