diff --git a/src/main/java/com/peteralbus/controller/PhotoController.java b/src/main/java/com/peteralbus/controller/PhotoController.java index a4e7fa7..7c17e30 100644 --- a/src/main/java/com/peteralbus/controller/PhotoController.java +++ b/src/main/java/com/peteralbus/controller/PhotoController.java @@ -97,4 +97,29 @@ public class PhotoController return "error:"+e.getMessage(); } } + + /** + * Custom upload string. + * + * @param file the file + * @param path the path + * @return the string + */ + @PostMapping("/uploadOriginImg") + public String uploadOriginImg(@RequestParam("file") MultipartFile file,String path) + { + /*pathExample:blog/imgs/photo/*/ + String uploadPath="/home/PeterAlbus/assets/"+path; + // 获取上传的文件名称 + String fileName = file.getOriginalFilename(); + File dest = new File(uploadPath + fileName); + try { + // 上传的文件被保存了 + file.transferTo(dest); + return "https://www.peteralbus.com:8440/assets/"+path+fileName; + } catch (IOException e) { + e.printStackTrace(); + return "error:"+e.getMessage(); + } + } } diff --git a/src/main/java/com/peteralbus/service/PhotoService.java b/src/main/java/com/peteralbus/service/PhotoService.java index c9777a8..0a591b7 100644 --- a/src/main/java/com/peteralbus/service/PhotoService.java +++ b/src/main/java/com/peteralbus/service/PhotoService.java @@ -4,10 +4,25 @@ import com.peteralbus.domain.Photo; import java.util.List; -/*Created on 2021/7/29.*/ -/*@author PeterAlbus*/ + +/** + * The interface Photo service. + * @author PeterAlbus + */ public interface PhotoService { + /** + * Query all list. + * + * @return the list + */ List queryAll(); + + /** + * Add int. + * + * @param photo the photo + * @return the int + */ int add(Photo photo); }