This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
@ConditionalOnProperty(value = "mock.azure.blobstorage.service.enabled", havingValue = "true") | |
public class MockBlobStorageService implements BlobStorageService{ | |
@Override | |
public URI uploadPicture(MultipartFile multipartFile) { | |
return URI.create("https://mahallemstorage.blob.core.windows.net/testmahallem/mordor_ale.png"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mock: | |
azure.blobstorage.service.enabled: true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequiredArgsConstructor | |
@Repository | |
public class UserRepositoryImpl implements UserRepository { | |
@NotNull | |
private final MongoTemplate mongoTemplate; | |
@Override | |
public void uploadProfilePicture(String url, ObjectId id) { | |
UpdateResult updateResult = mongoTemplate.updateFirst(Query.query(Criteria.where("_id").is(id)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
@RequiredArgsConstructor | |
public class UserServiceImpl implements UserService { | |
private final UserRepository userRepository; | |
private final BlobStorageService blobStorageService; | |
@NotNull | |
final MongoTemplate mongoTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/user") | |
@RequiredArgsConstructor | |
public class UserController { | |
private final UserService userService; | |
@PostMapping("upload-profile-picture") | |
public ResponseEntity<MainResponse<UserResponse>> writeBlobFile(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest httpServletRequest) throws IOException { | |
String userId = JwtUtil.getObjectIdFromRequest(httpServletRequest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
@RequiredArgsConstructor | |
@ConditionalOnProperty(value = "mock.azure.blobstorage.service.enabled", havingValue = "false", matchIfMissing = true) | |
public class BlobStorageServiceImpl implements BlobStorageService { | |
private final Logger LOGGER = LoggerFactory.getLogger(BlobStorageServiceImpl.class); | |
private final CloudBlobContainer cloudBlobContainer; | |
@Override | |
public URI uploadPicture(MultipartFile multipartFile) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface BlobStorageService { | |
public URI uploadPicture(MultipartFile multipartFile); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.microsoft.azure</groupId> | |
<artifactId>azure-storage</artifactId> | |
<version>8.4.0</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
azure: | |
blob: | |
store: | |
connectionString: ${azure_blob_store_connection_string} | |
containerName: ${azure_blob_store_connection_name} |