Skip to content

Commit

Permalink
fix: 禅道图片同步上传问题
Browse files Browse the repository at this point in the history
  • Loading branch information
song-cc-rock committed Mar 22, 2024
1 parent adfe4c3 commit 6dd692c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ public Map<String, Object> getBuildsV17(String projectId) {
return (Map<String, Object>) JSON.parseMap(response.getBody()).get("data");
}

public String uploadFile(File file) {
public String uploadFile(File file, String projectKey) {
String id = "";
String sessionId = login();
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
paramMap.add("files", new FileSystemResource(file));
try {
ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl.getFileUpload(), HttpMethod.POST, getHttpEntity(paramMap),
String.class, null, sessionId);
String.class, projectKey, sessionId);
String body = responseEntity.getBody();
Map obj = JSON.parseMap(body);
Map data = (Map) JSON.parseObject(obj.get("data").toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ else if (data.charAt(0) == '{') {
return list;
}

private String ms2ZentaoDescription(String msDescription) {
private String ms2ZentaoDescription(String msDescription, String projectId) {
String imgUrlRegex = "!\\[.*?]\\(/resource/md/get(.*?\\..*?)\\)";
String zentaoSteps = msDescription.replaceAll(imgUrlRegex, zentaoClient.requestUrl.getReplaceImgUrl());
Matcher matcher = zentaoClient.requestUrl.getImgPattern().matcher(zentaoSteps);
Expand All @@ -506,7 +506,7 @@ private String ms2ZentaoDescription(String msDescription) {
String fileName = originSubUrl.substring(10);
// upload zentao
try {
String id = zentaoClient.uploadFile(getRealMdFile(fileName));
String id = zentaoClient.uploadFile(getRealMdFile(fileName), projectId);
// todo delete local file
int index = fileName.lastIndexOf(".");
String suffix = "";
Expand Down Expand Up @@ -686,7 +686,7 @@ private MultiValueMap<String, Object> buildUpdateParam(PlatformIssuesUpdateReque

// transfer description
try {
zentaoSteps = ms2ZentaoDescription(description);
zentaoSteps = ms2ZentaoDescription(description, projectId);
zentaoSteps = zentaoSteps.replaceAll("\\n", "<br/>");
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
Expand Down

0 comments on commit 6dd692c

Please sign in to comment.