Changes for fallback option
This commit is contained in:
parent
200f802277
commit
07b65a6d33
|
@ -6,7 +6,6 @@ import org.springframework.web.bind.annotation.RequestPart;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.baeldung.cloud.openfeign.exception.NotFoundException;
|
||||
import com.baeldung.cloud.openfeign.fileupload.service.UploadService;
|
||||
|
||||
@RestController
|
||||
|
@ -16,8 +15,7 @@ public class FileController {
|
|||
private UploadService service;
|
||||
|
||||
@PostMapping(value = "/upload-mannual-client")
|
||||
public boolean handleFileUploadWithManualClient(
|
||||
@RequestPart(value = "file") MultipartFile file) {
|
||||
public boolean handleFileUploadWithManualClient(@RequestPart(value = "file") MultipartFile file) {
|
||||
return service.uploadFileWithManualClient(file);
|
||||
}
|
||||
|
||||
|
@ -27,13 +25,12 @@ public class FileController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/upload-with-fallbackfactory")
|
||||
public String uploadFileWithFallbackFactory(@RequestPart(value = "file") MultipartFile file)
|
||||
throws NotFoundException {
|
||||
public String uploadFileWithFallbackFactory(@RequestPart(value = "file") MultipartFile file) {
|
||||
return service.uploadFileWithFallbackFactory(file);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/upload-with-fallback")
|
||||
public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) throws NotFoundException {
|
||||
public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) {
|
||||
return service.uploadFileWithFallback(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.baeldung.cloud.openfeign.exception.NotFoundException;
|
||||
|
||||
import feign.Feign;
|
||||
import feign.Response;
|
||||
import feign.form.spring.SpringFormEncoder;
|
||||
|
@ -26,11 +24,11 @@ public class UploadService {
|
|||
return response.status() == 200;
|
||||
}
|
||||
|
||||
public String uploadFileWithFallbackFactory(MultipartFile file) throws NotFoundException {
|
||||
public String uploadFileWithFallbackFactory(MultipartFile file) {
|
||||
return fileUploadClient.fileUpload(file);
|
||||
}
|
||||
|
||||
public String uploadFileWithFallback(MultipartFile file) throws NotFoundException {
|
||||
public String uploadFileWithFallback(MultipartFile file) {
|
||||
return fileUploadClientWithFallback.fileUpload(file);
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ public class OpenFeignFileUploadLiveTest {
|
|||
FileInputStream input = new FileInputStream(file);
|
||||
MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain",
|
||||
IOUtils.toByteArray(input));
|
||||
Assert.assertTrue(uploadService.uploadFileWithManualClient(multipartFile));
|
||||
uploadService.uploadFileWithFallback(multipartFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -44,7 +44,6 @@ public class OpenFeignFileUploadLiveTest {
|
|||
FileInputStream input = new FileInputStream(file);
|
||||
MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain",
|
||||
IOUtils.toByteArray(input));
|
||||
String uploadFile = uploadService.uploadFile(multipartFile);
|
||||
Assert.assertNotNull(uploadFile);
|
||||
uploadService.uploadFileWithFallbackFactory(multipartFile);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue