|
@@ -4,15 +4,21 @@ import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.boot.core.fss.store.FileStore;
|
|
|
+import com.qmth.boot.core.retrofit.utils.UploadFile;
|
|
|
+import com.qmth.boot.tools.models.ByteArray;
|
|
|
+import com.qmth.demo.api.client.FileTestClient;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/file")
|
|
|
-@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
|
|
|
+@Aac(auth = BOOL.FALSE)
|
|
|
public class FileController {
|
|
|
|
|
|
// @Resource
|
|
@@ -21,6 +27,9 @@ public class FileController {
|
|
|
@Resource
|
|
|
FileStore fileStore;
|
|
|
|
|
|
+ @Resource
|
|
|
+ FileTestClient fileTestClient;
|
|
|
+
|
|
|
@RequestMapping("/server")
|
|
|
public Object server() {
|
|
|
//return fileService.getFileStore("public").getServer();
|
|
@@ -32,4 +41,23 @@ public class FileController {
|
|
|
//return fileService.getFileStore("public").exist(path);
|
|
|
return fileStore.exist(path);
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/upload")
|
|
|
+ public Object upload(@RequestParam String path, @RequestParam String md5, @RequestParam MultipartFile file)
|
|
|
+ throws Exception {
|
|
|
+ fileStore.write(path, file.getInputStream(), md5);
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/client/upload")
|
|
|
+ public Object clientUpload(@RequestParam String path, @RequestParam String name) throws Exception {
|
|
|
+ File file = new File(path);
|
|
|
+ String md5 = ByteArray.md5(file).toHexString();
|
|
|
+ return fileTestClient.upload(name, md5, UploadFile.build("file", name, file));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/client/server")
|
|
|
+ public Object clientServer() throws IOException {
|
|
|
+ return fileTestClient.getServer();
|
|
|
+ }
|
|
|
}
|