File uploading becomes very easy with the support of the NIO libraries and Spring's MultipartFile options. Here, we will add the code for file uploading.
The FileUploadService interface will look as follows:
package com.packtpub.service;
import org.springframework.web.multipart.MultipartFile;
public interface FileUploadService {
void uploadFile(MultipartFile file) throws IOException;
}
In the preceding code, we just defined the method to let the concrete class (implementation class) override our method. We used MultipartFile here to forward a file, such as a media file to fulfill our business logic.
The FileUploadServerImpl class implementation is as follows:
package com.packtpub.service;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java...