Skip to content

Commit 8c7eb1e

Browse files
committed
Update rest api
1 parent 118ccbd commit 8c7eb1e

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Book-RESTful-Service/src/main/java/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.springframework.context.annotation.ComponentScan;
66

77
@SpringBootApplication
8-
@ComponentScan("com.howtoprogram.book")
8+
@ComponentScan({"com.howtoprogram.book", "com.howtoprogram.service"})
99
public class Application {
1010

1111
public static void main(String[] args) {

Book-RESTful-Service/src/main/java/com/howtoprogram/service/FileSystemStorageService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.howtoprogram.service;
22

33
import java.io.IOException;
4-
import java.nio.file.Files;
5-
import java.nio.file.Path;
6-
import java.nio.file.Paths;
4+
import java.nio.file.*;
75

86
import org.springframework.stereotype.Service;
97
import org.springframework.web.multipart.MultipartFile;
@@ -20,7 +18,7 @@ public void store(MultipartFile file) {
2018
"Failed to store empty file " + file.getOriginalFilename());
2119
}
2220
Files.copy(file.getInputStream(),
23-
this.rootLocation.resolve(file.getOriginalFilename()));
21+
this.rootLocation.resolve(file.getOriginalFilename()), StandardCopyOption.REPLACE_EXISTING);
2422
} catch (IOException e) {
2523
throw new StorageException("Failed to store file " + file.getOriginalFilename(), e);
2624
}

0 commit comments

Comments
 (0)