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