fix: fix minor bugs and change config to ec2 instance
This commit is contained in:
@ -64,7 +64,7 @@ public class S3FileHandler {
|
|||||||
.created(URI.create("/files"))
|
.created(URI.create("/files"))
|
||||||
.body(new DirectoryPath(
|
.body(new DirectoryPath(
|
||||||
path.resolve(
|
path.resolve(
|
||||||
file.getSubmittedFileName()
|
file.getSubmittedFileName().replaceAll("\s", "_")
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -3,6 +3,7 @@ package ua.com.dxrkness.controller;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import org.springframework.web.servlet.function.RouterFunction;
|
import org.springframework.web.servlet.function.RouterFunction;
|
||||||
import org.springframework.web.servlet.function.RouterFunctions;
|
import org.springframework.web.servlet.function.RouterFunctions;
|
||||||
@ -35,4 +36,10 @@ public class S3FileHandlerConfig implements WebMvcConfigurer {
|
|||||||
.allowedHeaders("*")
|
.allowedHeaders("*")
|
||||||
.allowedOriginPatterns("*");
|
.allowedOriginPatterns("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("/public/**")
|
||||||
|
.addResourceLocations("classpath:/static/");
|
||||||
|
}
|
||||||
}
|
}
|
@ -102,7 +102,7 @@ public class S3Service {
|
|||||||
client.putObject(b -> b
|
client.putObject(b -> b
|
||||||
.bucket(bucketName)
|
.bucket(bucketName)
|
||||||
.key(destinationPath
|
.key(destinationPath
|
||||||
.resolve(file.getSubmittedFileName())
|
.resolve(file.getSubmittedFileName().replace("\s", "_"))
|
||||||
.toString()),
|
.toString()),
|
||||||
RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
|
RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,14 @@
|
|||||||
<button onclick="navigateToPath()">Go to Path</button>
|
<button onclick="navigateToPath()">Go to Path</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>Just a meme from S3 bucket</h3>
|
||||||
|
<img width="40%"
|
||||||
|
src="https://student-test-bucket-orlovos-2025.s3.eu-central-1.amazonaws.com/meme.jpg">
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const baseUrl = 'http://localhost:8080';
|
const baseUrl = 'http://18.199.97.136:8080';
|
||||||
let currentPath = '';
|
let currentPath = '';
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
Reference in New Issue
Block a user