Skip to content

Commit

Permalink
feature: Integration with OCI Object Storage temp
Browse files Browse the repository at this point in the history
task:  8697bjvqr
  • Loading branch information
KinTrae committed Jan 8, 2025
1 parent 5a1000f commit fc10f48
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package meowhub.backend.ext.oci;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.web.multipart.MultipartFile;

@Configuration
@Profile("mock-oci")
public class MockOCIUploadServiceConfig {
@Bean
@Primary
public OCIUploadService mockOCIUploadService() {
return new OCIUploadService() {
@Override
public void upload(MultipartFile file, String objectName) throws Exception {
System.out.println("Mock upload: " + objectName);
}

@Override
public String getFileObjectUrl(String objectName) throws Exception {
return "https://mock.objectstorage.local/" + objectName;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.objectstorage.ObjectStorage;
import com.oracle.bmc.objectstorage.ObjectStorageClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import java.io.IOException;

@Configuration
@Profile("!mock-oci")
public class OCIClientConfiguration {
// Path to OCI configs file
String configurationFilePath = "backend/src/main/resources/config";
String profile = "DEFAULT";

@Bean
public ObjectStorage getObjectStorage() throws IOException {
//load configs file
final ConfigFileReader.ConfigFile configFile = ConfigFileReader.parse(configurationFilePath, profile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.oracle.bmc.objectstorage.responses.CreatePreauthenticatedRequestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import meowhub.backend.posts.services.PostService;
import meowhub.backend.shared.constants.AlertConstants;
import meowhub.backend.shared.dtos.PictureDto;
import meowhub.backend.shared.pictures.PictureUtils;
import meowhub.backend.shared.utils.PictureUtils;
import meowhub.backend.users.dtos.BasicUserInfoDto;
import meowhub.backend.users.facades.UserPostServiceFacade;
import meowhub.backend.users.models.User;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package meowhub.backend.shared.pictures;
package meowhub.backend.shared.utils;

import lombok.RequiredArgsConstructor;
import meowhub.backend.ext.oci.OCIUploadService;
Expand Down
Empty file.
7 changes: 6 additions & 1 deletion frontend/src/Features/CreatePost/CreatePost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export const CreatePost = () => {
return;
}

api.post('/api/posts', null, {params: {content: contentToSave}}).then((response) => {
api.post('/api/posts', null, {
params: {content: contentToSave},
headers: {
'Content-Type': 'multipart/form-data'
}
}).then((response) => {
if (response.status === 200) {
close();
}
Expand Down

0 comments on commit fc10f48

Please sign in to comment.