Remove unwanted changes from Old Module

This commit is contained in:
Amitabh Tiwari 2022-07-22 16:52:08 +05:30
parent 717afd3f5e
commit 24a8399b6b
3 changed files with 3 additions and 27 deletions

View File

@ -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
@ -27,8 +26,8 @@ public class FileController {
}
@PostMapping(value = "/upload-error")
public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) throws NotFoundException {
return service.uploadFileWithCause(file);
public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) {
return service.uploadFile(file);
}
}

View 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);
}

View 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;
@ -16,9 +14,7 @@ public class UploadService {
@Autowired
private UploadClient client;
@Autowired
private FileUploadClient fileUploadClient;
public boolean uploadFileWithManualClient(MultipartFile file) {
UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder())
.target(UploadResource.class, HTTP_FILE_UPLOAD_URL);
@ -33,8 +29,4 @@ public class UploadService {
public String uploadFileError(MultipartFile file) {
return client.fileUpload(file);
}
public String uploadFileWithCause(MultipartFile file) throws NotFoundException {
return fileUploadClient.fileUpload(file);
}
}