@Override
public FileVO getFile(Long id, String encoding) {
try {
FileEntity file = getDao().getFileDao().getById(id);
FileVO vo = new FileVO(file);
FolderEntity folder = getDao().getFolderDao().getById(file
.getFolderId());
vo.setLink("/file" + getBusiness().getFolderBusiness()
.getFolderPath(folder) + "/" + file.getFilename());
String ext = FolderUtil.getFileExt(file.getFilename());
vo.setTextFile(getBusiness().getConfigBusiness().isTextFileExt(ext));
vo.setImageFile(getBusiness().getConfigBusiness()
.isImageFileExt(ext));
if (vo.isTextFile()) {
vo.setContent(new String(getDao().getFileDao()
.getFileContent(file), encoding));
}
return vo;
}
catch (Exception e) {