Skip to content

Commit

Permalink
fix : 이미지 타입이 image/jpeg가 아니라 application/octet-stream 로 업로드가 되어 화면에서…
Browse files Browse the repository at this point in the history
… 사진을 보여줄때 다운로드가 되어버림. 그래서 image Type을 변경하는 로직을 작성.
  • Loading branch information
voka committed Oct 18, 2023
1 parent 6e45c77 commit ff5fa06
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public String imageUpload(String objectName, MultipartFile image) {
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(keyPath));
Storage storage = StorageOptions.newBuilder().setProjectId(projectId).setCredentials(credentials).build().getService();
BlobId blobId = BlobId.of(bucketName, objectName);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).build();
BlobInfo blobInfo = BlobInfo.newBuilder(blobId)
.setContentType("image/jpeg").build();
storage.create(blobInfo,image.getBytes());
System.out.println(
"File uploaded to bucket " + bucketName + " as " + objectName);
Expand Down

0 comments on commit ff5fa06

Please sign in to comment.