|
@ -12,14 +12,6 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.HttpResponse;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@ -34,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@ -42,7 +33,6 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@ -568,6 +558,53 @@ public class FileUploadController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 图片上传
|
|
|
*
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
* @throws IllegalStateException
|
|
|
*/
|
|
|
@RequestMapping(value = "pcimage", method = RequestMethod.POST /*,headers = "Accept=image/png"*/ )
|
|
|
@ResponseBody
|
|
|
public String pcimage(HttpServletRequest request, HttpServletResponse response) {
|
|
|
if (isneiwang) {
|
|
|
// 圖片列表
|
|
|
List<String> tempPaths = new ArrayList<String>();
|
|
|
try {
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
// 上传文件
|
|
|
MultipartFile mf = entity.getValue();
|
|
|
InputStream inputStream = mf.getInputStream();
|
|
|
String fileName = mf.getOriginalFilename().substring(0,mf.getOriginalFilename().lastIndexOf("."));
|
|
|
ObjectNode imgNode = FastDFSUtil.upload(inputStream,"png",fileName);
|
|
|
tempPaths.add(imgNode.get("fid").toString());
|
|
|
}
|
|
|
String urls = "";
|
|
|
for (String image : tempPaths) {
|
|
|
if (urls.length() == 0) {
|
|
|
urls = image;
|
|
|
} else {
|
|
|
urls += "," + image;
|
|
|
}
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("status", 200);
|
|
|
json.put("msg", "上传成功");
|
|
|
json.put("urls", urls);
|
|
|
logger.info("图片上传:" + json.toString());
|
|
|
return json.toString();
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "上传失败");
|
|
|
}
|
|
|
} else {
|
|
|
return CommonUtil.toNeiWang(request, response);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// @RequestMapping(value = "fastDFSImags", method = RequestMethod.POST)
|
|
|
// @ApiOperation("编辑文章上传图片")
|
|
|
// @ResponseBody
|