| | |
| | | // 文件保存目录路径 |
| | | String savePath = fileStoragePath; |
| | | String abstractPath= DateUtil.dateFormatStr(new Date(),DateUtil.DATE_FORMAT_NO_SPLITE_DD); |
| | | savePath=savePath+File.separator+abstractPath; |
| | | |
| | | String fileName =UUIDUtil.getRandomID() + ".png"; |
| | | |
| | | |
| | |
| | | uploadDir.mkdir(); |
| | | } |
| | | |
| | | ImageUtil.base64ToFile(uploadPhotoDto.getBase64(), savePath+File.separator+abstractPath, fileName); |
| | | ImageUtil.base64ToFile(uploadPhotoDto.getBase64(),savePath , fileName); |
| | | LogUtil.info("fileName : {}", fileName); |
| | | |
| | | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("上传成功"); |
| | | ajaxResult.putInMap("file", nginxUrl +"/"+ abstractPath+fileName); |
| | | ajaxResult.putInMap("file", nginxUrl + abstractPath+"/"+fileName); |
| | | return ajaxResult; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | public static String base64ToFile(String base64Str, String savePath, String fileName) { |
| | | String fileDir = DateUtil.dateToString(new Date(), DateUtil.DATE_FORMAT_NO_SPLITE_DD); |
| | | |
| | | File dir = new File(savePath + fileDir); |
| | | |
| | | File dir = new File(savePath); |
| | | if (!dir.isDirectory()) { |
| | | dir.mkdir(); |
| | | } |
| | |
| | | BufferedOutputStream bos = null; |
| | | FileOutputStream fos = null; |
| | | File file = null; |
| | | String filePathAndName = fileDir + File.separator + fileName; |
| | | String filePathAndName = dir + File.separator + fileName; |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | byte[] bfile = new byte[0]; |
| | | try { |
| | |
| | | |
| | | #文件保存地址 |
| | | #file_storage_path=/mnt/hive/static/uploadeFile/ |
| | | file_storage_path=/Users/jiangyouyao/java/webresources/ |
| | | file_storage_path=E:\\20210116 |
| | | #文件上传大小字节为单位 10MB |
| | | maxUploadSize=10485760 |
| | | |