|
@ -30,6 +30,8 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
@ -50,6 +52,7 @@ import org.springframework.web.multipart.MultipartRequest;
|
|
@Api(description = "文件上传")
|
|
@Api(description = "文件上传")
|
|
public class FileUploadController extends BaseController {
|
|
public class FileUploadController extends BaseController {
|
|
|
|
|
|
|
|
private Logger logger= LoggerFactory.getLogger(FileUploadController.class);
|
|
@ApiParam
|
|
@ApiParam
|
|
FastDFSUtil fastDFSUtil;
|
|
FastDFSUtil fastDFSUtil;
|
|
@Autowired
|
|
@Autowired
|
|
@ -93,7 +96,7 @@ public class FileUploadController extends BaseController {
|
|
json.put("msg", "上传成功");
|
|
json.put("msg", "上传成功");
|
|
// 图片标识对象的HTTP链接
|
|
// 图片标识对象的HTTP链接
|
|
json.put("urls", String.join(",", firstPhoto));
|
|
json.put("urls", String.join(",", firstPhoto));
|
|
System.out.println("图片上传:" + json.toString());
|
|
|
|
|
|
logger.info("图片上传:" + json.toString());
|
|
return json.toString();
|
|
return json.toString();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
error(e);
|
|
error(e);
|
|
@ -161,7 +164,7 @@ public class FileUploadController extends BaseController {
|
|
json.put("msg", "上传成功");
|
|
json.put("msg", "上传成功");
|
|
// 图片标识对象的HTTP链接
|
|
// 图片标识对象的HTTP链接
|
|
json.put("urls", urls);
|
|
json.put("urls", urls);
|
|
System.out.println("图片上传:" + json.toString());
|
|
|
|
|
|
logger.info("图片上传:" + json.toString());
|
|
return json.toString();
|
|
return json.toString();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
error(e);
|
|
error(e);
|
|
@ -273,7 +276,7 @@ public class FileUploadController extends BaseController {
|
|
json.put("msg", "上传成功");
|
|
json.put("msg", "上传成功");
|
|
// 图片标识对象的HTTP链接
|
|
// 图片标识对象的HTTP链接
|
|
json.put("urls", urls);
|
|
json.put("urls", urls);
|
|
System.out.println("附件上传:" + json.toString());
|
|
|
|
|
|
logger.info("附件上传:" + json.toString());
|
|
return json.toString();
|
|
return json.toString();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
error(e);
|
|
error(e);
|
|
@ -339,7 +342,7 @@ public class FileUploadController extends BaseController {
|
|
json.put("msg", "上传成功");
|
|
json.put("msg", "上传成功");
|
|
// 图片标识对象的HTTP链接
|
|
// 图片标识对象的HTTP链接
|
|
json.put("urls", urls);
|
|
json.put("urls", urls);
|
|
System.out.println("语音上传:" + json.toString());
|
|
|
|
|
|
logger.info("语音上传:" + json.toString());
|
|
return json.toString();
|
|
return json.toString();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
error(e);
|
|
error(e);
|
|
@ -468,7 +471,7 @@ public class FileUploadController extends BaseController {
|
|
json.put("msg", "上传成功");
|
|
json.put("msg", "上传成功");
|
|
// 图片标识对象的HTTP链接
|
|
// 图片标识对象的HTTP链接
|
|
json.put("urls", urls);
|
|
json.put("urls", urls);
|
|
System.out.println("图片上传:" + json.toString());
|
|
|
|
|
|
logger.info("图片上传:" + json.toString());
|
|
return json.toString();
|
|
return json.toString();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
error(e);
|
|
error(e);
|
|
@ -515,7 +518,7 @@ public class FileUploadController extends BaseController {
|
|
|
|
|
|
private String request(String remote_url, MultipartFile file) {
|
|
private String request(String remote_url, MultipartFile file) {
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
System.out.println(file.getOriginalFilename());
|
|
|
|
|
|
logger.info(file.getOriginalFilename());
|
|
String result = "";
|
|
String result = "";
|
|
try {
|
|
try {
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|