log:add log
This commit is contained in:
parent
032ffbd876
commit
bf0a2d06e4
@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.ensign.crm.module.crm.exception.AllKingdeeException;
|
||||
import com.ensign.crm.module.crm.model.ImageStorage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
@ -168,6 +169,7 @@ public class ProxyService {
|
||||
String target = initBasePath() + path.replace("/crm-api/proxy/file/do", "");
|
||||
String accessToken = initAccessToken();
|
||||
target = target + "?access_token=" + accessToken;
|
||||
log.info("proxy target: {}",target);
|
||||
URI newUri = new URI(target);
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(newUri);
|
||||
@ -176,9 +178,18 @@ public class ProxyService {
|
||||
builder.addPart("file", fileBody);
|
||||
HttpEntity multipartEntity = builder.build();
|
||||
httpPost.setEntity(multipartEntity);
|
||||
Header[] requestHeader = httpPost.getAllHeaders();
|
||||
for (Header header : requestHeader) {
|
||||
log.info("request Header: {}: {}", header.getName(), header.getValue());
|
||||
}
|
||||
HttpResponse kResponse = httpClient.execute(httpPost);
|
||||
Header[] headers = kResponse.getAllHeaders();
|
||||
for (Header header : headers) {
|
||||
log.info("response Header: {}: {}", header.getName(), header.getValue());
|
||||
}
|
||||
HttpEntity entity = kResponse.getEntity();
|
||||
String jsonStr = EntityUtils.toString(entity, "UTF-8").trim();
|
||||
log.info("receive response: {}", jsonStr);
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
if (jsonObject.containsKey("url")) {
|
||||
String url = jsonObject.getString("url");
|
||||
@ -193,14 +204,19 @@ public class ProxyService {
|
||||
imageStorage.setFileContent(transformToBase64(bytes));
|
||||
|
||||
imageService.saveImage(fileId, imageStorage);
|
||||
return doConvertFileUrl(fileId, true);
|
||||
String convertFileUrl = doConvertFileUrl(fileId, true);
|
||||
log.info("convertFileUrl: {}", convertFileUrl);
|
||||
return convertFileUrl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getFileMediaType(String filename) {
|
||||
log.info("filename: {}", filename);
|
||||
Optional<MediaType> mediaType = MediaTypeFactory.getMediaType(filename);
|
||||
return mediaType.map(MimeType::toString).orElse("");
|
||||
String type = mediaType.map(MimeType::toString).orElse("");
|
||||
log.info("mediaType: {}", type);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user