Merge pull request #53 from HideyoshiSolutions/fixes-storage-service-implementation
Fixes StorageService Implementation
This commit is contained in:
@@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class StorageServiceDownloadResponse {
|
||||
|
||||
@JsonProperty("presigned_url")
|
||||
private String presignedUrl;
|
||||
@JsonProperty("signed_url")
|
||||
private String signedUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class StorageServiceUploadResponse {
|
||||
|
||||
@JsonProperty("presigned_url")
|
||||
private String presignedUrl;
|
||||
@JsonProperty("signed_url")
|
||||
private String signedUrl;
|
||||
|
||||
@JsonProperty("file_key")
|
||||
private String fileKey;
|
||||
@JsonProperty("expires_in")
|
||||
private String expiresIn;
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ import static java.util.Arrays.stream;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthService {
|
||||
private static final String AUTHORIZATION_TYPE_STRING = "Bearer ";
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final StorageService storageService;
|
||||
@@ -166,7 +164,7 @@ public class AuthService {
|
||||
|
||||
private String extractProfilePictureUrl(UserDTO user) {
|
||||
return this.storageService.getFileUrl(user.getUsername(), "profile")
|
||||
.map(StorageServiceDownloadResponse::getPresignedUrl)
|
||||
.map(StorageServiceDownloadResponse::getSignedUrl)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class StorageService {
|
||||
|
||||
private final StorageServiceConfig storageServiceConfig;
|
||||
|
||||
private final String PARAMETER_USERNAME = "username";
|
||||
private final String PARAMETER_FILE_KEY = "file_key";
|
||||
|
||||
private final String PARAMETER_FILE_POSTFIX = "file_postfix";
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StorageService {
|
||||
|
||||
public Optional<StorageServiceUploadResponse> getNewFileUrl(String username, String filePostfix, FileTypeEnum fileTypeEnum) {
|
||||
HashMap<String, String> values = new HashMap<>() {{
|
||||
put(PARAMETER_USERNAME, username);
|
||||
put(PARAMETER_FILE_KEY, username);
|
||||
put(PARAMETER_FILE_POSTFIX, filePostfix);
|
||||
put(PARAMETER_FILE_TYPE, fileTypeEnum.getFileExtension());
|
||||
}};
|
||||
@@ -66,7 +66,7 @@ public class StorageService {
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URIBuilder(storageServiceConfig.getFileServicePath() + "/file")
|
||||
.addParameter(PARAMETER_USERNAME, username)
|
||||
.addParameter(PARAMETER_FILE_KEY, username)
|
||||
.addParameter(PARAMETER_FILE_POSTFIX, filePostfix)
|
||||
.build();
|
||||
} catch (URISyntaxException e) {
|
||||
@@ -90,7 +90,7 @@ public class StorageService {
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URIBuilder(storageServiceConfig.getFileServicePath() + "/file")
|
||||
.addParameter(PARAMETER_USERNAME, username)
|
||||
.addParameter(PARAMETER_FILE_KEY, username)
|
||||
.addParameter(PARAMETER_FILE_POSTFIX, filePostfix)
|
||||
.build();
|
||||
} catch (URISyntaxException e) {
|
||||
@@ -106,7 +106,7 @@ public class StorageService {
|
||||
|
||||
public void processFile(String username, String filePostfix) {
|
||||
HashMap<String, String> values = new HashMap<>() {{
|
||||
put(PARAMETER_USERNAME, username);
|
||||
put(PARAMETER_FILE_KEY, username);
|
||||
put(PARAMETER_FILE_POSTFIX, filePostfix);
|
||||
}};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class StorageServiceTest {
|
||||
|
||||
// When
|
||||
try {
|
||||
String responseString = "{\"presigned_url\":\"https://test.com\", \"file_key\":\"test\"}";
|
||||
String responseString = "{\"signed_url\":\"https://test.com\", \"expires_in\":\"3600\"}";
|
||||
Mockito.doReturn(responseString).when(storageService).postRequest(Mockito.any(), Mockito.any());
|
||||
} catch (IOException e) {
|
||||
assert false;
|
||||
@@ -85,7 +85,7 @@ public class StorageServiceTest {
|
||||
|
||||
// When
|
||||
try {
|
||||
String responseString = "{\"presigned_url\":\"http://test.com\"}";
|
||||
String responseString = "{\"signed_url\":\"http://test.com\"}";
|
||||
Mockito.doReturn(responseString).when(storageService).getRequest(Mockito.any());
|
||||
} catch (IOException e) {
|
||||
assert false;
|
||||
|
||||
Reference in New Issue
Block a user