Skip to content

Commit

Permalink
fix: 이미지 검색 null 예외처리
Browse files Browse the repository at this point in the history
  • Loading branch information
Gdm0714 committed Mar 27, 2024
1 parent 18c5a36 commit 58fa6fa
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String uploadImage(MultipartFile image, String fileName) throws IOExcepti

public String getImageUrlsWithKeyword(String keyword) {
List<String> imageUrls = new ArrayList<>();

String url = "";
ListObjectsV2Request request = new ListObjectsV2Request()
.withBucketName(bucketName)
.withPrefix(""); // 모든 객체를 검색하려면 prefix를 비워둡니다.
Expand All @@ -61,8 +61,11 @@ public String getImageUrlsWithKeyword(String keyword) {
}
request.setContinuationToken(result.getNextContinuationToken());
} while (result.isTruncated());
String imageUrl = imageUrls.get(0);
return imageUrl;
if(!imageUrls.isEmpty()) url = imageUrls.get(0);
else{
return null;
}
return url;
}
}

0 comments on commit 58fa6fa

Please sign in to comment.