Skip to content

Commit

Permalink
Merge branch 'staging' into feature/#25-deploy-aws-cdk
Browse files Browse the repository at this point in the history
  • Loading branch information
nookcoder authored Aug 9, 2023
2 parents bd77885 + ab842a2 commit bcfb11a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repositories {
}

dependencies {
implementation 'org.springframework:spring-test:5.3.10'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-web'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AwsBluePrintDto {
private List<AwsAreaDto> areas;
private List<AwsComponentDto> components;
private List<ComponentLineDto> links;
private MultipartFile svgFile;
private String svgFile;

public static List<AwsAreaDto> awsAreaDtosMapper(List<AwsArea> awsAreaDtos) {
List<AwsAreaDto> awsAreaDtoList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

import static java.lang.Boolean.parseBoolean;
Expand Down Expand Up @@ -85,7 +88,7 @@ public List<AwsBluePrintListDto> getMyAwsBlueprints(String oauthId) {
dto.setId(awsBluePrint.getId());
dto.setCreatedAt(awsBluePrint.getCreated_at());
dto.setStatus(awsBluePrint.getStatus());
dto.setPresignedUrl(awsBluePrint.getKeyName());
dto.setPresignedUrl(awsS3Helper.getPresignedUrl(awsBluePrint.getKeyName()));
awsBluePrintDtos.add(dto);
}
return awsBluePrintDtos;
Expand Down Expand Up @@ -164,7 +167,9 @@ private AwsBluePrint saveBlueprint(AwsBluePrintDto awsBluePrintDto, String provi
private String saveThumbnail(AwsBluePrintDto bluePrint, Member member) {
String objectKey = _getObjectKey(member.getOauthId(), bluePrint.getUuid());
try {
awsS3Helper.putS3Object(bluePrint.getSvgFile(), objectKey);
byte[] svgContent = Base64.getDecoder().decode(awsBluePrintDto.getSvgFile());
MultipartFile svgFile = new MockMultipartFile("file", objectKey, "image/svg+xml", svgContent);
awsS3Helper.putS3Object(svgFile, objectKey);
} catch (Exception e) {
logger.error("thumbnail upload failed: {}", e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void putS3Object(MultipartFile svgFile, String keyName) throws S3Exceptio
.bucket(s3Config.getBucket())
.key(keyName)
.build(),
RequestBody.fromFile(svgFile.getResource().getFile()));
RequestBody.fromInputStream(svgFile.getInputStream(), svgFile.getSize()));

logger.info("File uploaded to S3 bucket successfully");
} catch (S3Exception e) {
Expand Down

0 comments on commit bcfb11a

Please sign in to comment.