mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2025-04-05 17:37:49 +08:00
修复导包错误以及图片预览bug
This commit is contained in:
parent
f530f441d5
commit
7a7e1a1855
@ -5,7 +5,7 @@ import cn.keking.service.FilePreview;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
|
||||||
import static com.sun.glass.ui.Clipboard.TEXT_TYPE;
|
import static cn.keking.service.impl.SimTextFilePreviewImpl.TEXT_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kl (http://kailing.pub)
|
* @author kl (http://kailing.pub)
|
||||||
|
@ -44,11 +44,11 @@ public class PictureFilePreviewImpl implements FilePreview {
|
|||||||
String file = fileHandlerService.getRelativePath(response.getContent());
|
String file = fileHandlerService.getRelativePath(response.getContent());
|
||||||
imgUrls.clear();
|
imgUrls.clear();
|
||||||
imgUrls.add(file);
|
imgUrls.add(file);
|
||||||
model.addAttribute("imgurls", imgUrls);
|
model.addAttribute("imgUrls", imgUrls);
|
||||||
model.addAttribute("currentUrl", file);
|
model.addAttribute("currentUrl", file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("imgurls", imgUrls);
|
model.addAttribute("imgUrls", imgUrls);
|
||||||
model.addAttribute("currentUrl", url);
|
model.addAttribute("currentUrl", url);
|
||||||
}
|
}
|
||||||
return PICTURE_FILE_PREVIEW_PAGE;
|
return PICTURE_FILE_PREVIEW_PAGE;
|
||||||
|
@ -39,7 +39,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
|||||||
try {
|
try {
|
||||||
File originFile = new File(response.getContent());
|
File originFile = new File(response.getContent());
|
||||||
String xmlString = FileUtils.readFileToString(originFile, StandardCharsets.UTF_8);
|
String xmlString = FileUtils.readFileToString(originFile, StandardCharsets.UTF_8);
|
||||||
model.addAttribute("textData", Base64Utils.encodeToString(xmlString.getBytes()));
|
model.addAttribute("textData", Base64Utils.encodeToString(xmlString.getBytes(StandardCharsets.UTF_8)));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage());
|
return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import cn.keking.service.FilePreview;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
|
||||||
import static com.sun.glass.ui.Clipboard.TEXT_TYPE;
|
import static cn.keking.service.impl.SimTextFilePreviewImpl.TEXT_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kl (http://kailing.pub)
|
* @author kl (http://kailing.pub)
|
||||||
|
@ -65,6 +65,8 @@ public class OnlinePreviewController {
|
|||||||
if(StringUtils.hasText(currentUrl)){
|
if(StringUtils.hasText(currentUrl)){
|
||||||
String decodedCurrentUrl = new String(Base64Utils.decodeFromString(currentUrl));
|
String decodedCurrentUrl = new String(Base64Utils.decodeFromString(currentUrl));
|
||||||
model.addAttribute("currentUrl", decodedCurrentUrl);
|
model.addAttribute("currentUrl", decodedCurrentUrl);
|
||||||
|
}else {
|
||||||
|
model.addAttribute("currentUrl", imgUrls.get(0));
|
||||||
}
|
}
|
||||||
return PICTURE_FILE_PREVIEW_PAGE;
|
return PICTURE_FILE_PREVIEW_PAGE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user