Commit 175b0640 by 阳浪

文件上传

parent f7e15fdf
...@@ -28,15 +28,14 @@ public class FileUploadController { ...@@ -28,15 +28,14 @@ public class FileUploadController {
String pcHostUrl; String pcHostUrl;
@PostMapping("/upload") @PostMapping("/upload")
public Response<String> uploadFile(@RequestParam("file") MultipartFile file,@RequestParam("Filename")String Filename) { public Response<String> uploadFile(@RequestParam("file") MultipartFile file) {
try { try {
String[] fileNames = Filename.split("/");; String bucketName =propertiesUtil.getPublicParam().get("ossdir");;
String bucketName =fileNames[0]; String name = file.getOriginalFilename();
String name = fileNames[1];
minioTools.uplodFile(bucketName,name,file.getInputStream()); minioTools.uplodFile(bucketName,name,file.getInputStream());
return Response.ok(pcHostUrl+"/api/v1/buckets/"+bucketName+"/objects/download/?preview=true&prefix="+name); return Response.ok(pcHostUrl+"/api/v1/buckets/"+bucketName+"/objects/download/?preview=true&prefix="+name);
} catch (IOException ex) { } catch (IOException ex) {
return Response.fail("Could not upload the file: " + Filename); return Response.fail("Could not upload the file ");
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment