mirror of https://github.com/halo-dev/halo
Restrict file extension when importing markdown (#2104)
* fix #2090 * pass the check style * Revision * fix * fix * fix * fix * fix * fix * fix * revision * fix * Revision * revisionpull/2120/head
parent
c2e477fcab
commit
3dda1a9f6d
|
@ -141,7 +141,9 @@ public class BackupController {
|
||||||
backupService.deleteWorkDirBackup(filename);
|
backupService.deleteWorkDirBackup(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("markdown/import")
|
@PostMapping(value = "markdown/import", consumes = {
|
||||||
|
MediaType.TEXT_PLAIN_VALUE,
|
||||||
|
MediaType.TEXT_MARKDOWN_VALUE})
|
||||||
@ApiOperation("Imports markdown")
|
@ApiOperation("Imports markdown")
|
||||||
public BasePostDetailDTO backupMarkdowns(@RequestPart("file") MultipartFile file)
|
public BasePostDetailDTO backupMarkdowns(@RequestPart("file") MultipartFile file)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
|
@ -230,12 +230,16 @@ public class BackupServiceImpl implements BackupService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BasePostDetailDTO importMarkdown(MultipartFile file) throws IOException {
|
public BasePostDetailDTO importMarkdown(MultipartFile file) throws IOException {
|
||||||
|
try {
|
||||||
|
// Read markdown content.
|
||||||
|
String markdown = FileUtils.readString(file.getInputStream());
|
||||||
|
// TODO sheet import
|
||||||
|
return postService.importMarkdown(markdown, file.getOriginalFilename());
|
||||||
|
} catch (OutOfMemoryError error) {
|
||||||
|
throw new ServiceException(
|
||||||
|
"文件内容过大,无法导入。", error);
|
||||||
|
}
|
||||||
|
|
||||||
// Read markdown content.
|
|
||||||
String markdown = FileUtils.readString(file.getInputStream());
|
|
||||||
|
|
||||||
// TODO sheet import
|
|
||||||
return postService.importMarkdown(markdown, file.getOriginalFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue