add api of upload origin image

pangu
PeterAlbus 3 years ago
parent d32d2b9c19
commit e158ed345f

@ -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();
}
}
}

@ -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<Photo> queryAll();
/**
* Add int.
*
* @param photo the photo
* @return the int
*/
int add(Photo photo);
}

Loading…
Cancel
Save