1 changed files with 31 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.apache.commons.io.FileUtils; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestPart; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
@RestController |
|||
@RequestMapping("test") |
|||
public class TestController { |
|||
|
|||
@PostMapping("local-upload") |
|||
public Result localUpload(@RequestPart("file") MultipartFile file) { |
|||
|
|||
final File tempFile = new File("/opt/upload_files/temp"); |
|||
|
|||
try(InputStream inputStream = file.getInputStream()) { |
|||
FileUtils.copyInputStreamToFile(inputStream, tempFile); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return new Result(); |
|||
} |
|||
} |
Loading…
Reference in new issue