Remove unwanted changes from Old Module
This commit is contained in:
parent
717afd3f5e
commit
24a8399b6b
|
@ -6,7 +6,6 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import com.baeldung.cloud.openfeign.exception.NotFoundException;
|
|
||||||
import com.baeldung.cloud.openfeign.fileupload.service.UploadService;
|
import com.baeldung.cloud.openfeign.fileupload.service.UploadService;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -27,8 +26,8 @@ public class FileController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/upload-error")
|
@PostMapping(value = "/upload-error")
|
||||||
public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) throws NotFoundException {
|
public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) {
|
||||||
return service.uploadFileWithCause(file);
|
return service.uploadFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,15 +0,0 @@
|
||||||
package com.baeldung.cloud.openfeign.fileupload.service;
|
|
||||||
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig;
|
|
||||||
|
|
||||||
@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class)
|
|
||||||
public interface FileUploadClient {
|
|
||||||
@PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
||||||
String fileUpload(@RequestPart(value = "file") MultipartFile file);
|
|
||||||
}
|
|
|
@ -4,8 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import com.baeldung.cloud.openfeign.exception.NotFoundException;
|
|
||||||
|
|
||||||
import feign.Feign;
|
import feign.Feign;
|
||||||
import feign.Response;
|
import feign.Response;
|
||||||
import feign.form.spring.SpringFormEncoder;
|
import feign.form.spring.SpringFormEncoder;
|
||||||
|
@ -16,9 +14,7 @@ public class UploadService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UploadClient client;
|
private UploadClient client;
|
||||||
@Autowired
|
|
||||||
private FileUploadClient fileUploadClient;
|
|
||||||
|
|
||||||
public boolean uploadFileWithManualClient(MultipartFile file) {
|
public boolean uploadFileWithManualClient(MultipartFile file) {
|
||||||
UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder())
|
UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder())
|
||||||
.target(UploadResource.class, HTTP_FILE_UPLOAD_URL);
|
.target(UploadResource.class, HTTP_FILE_UPLOAD_URL);
|
||||||
|
@ -33,8 +29,4 @@ public class UploadService {
|
||||||
public String uploadFileError(MultipartFile file) {
|
public String uploadFileError(MultipartFile file) {
|
||||||
return client.fileUpload(file);
|
return client.fileUpload(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uploadFileWithCause(MultipartFile file) throws NotFoundException {
|
|
||||||
return fileUploadClient.fileUpload(file);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue