From 6a3942659d676b5af99954364ab770da95d4ac30 Mon Sep 17 00:00:00 2001 From: John Niang Date: Tue, 13 Aug 2024 23:01:52 +0800 Subject: [PATCH] Fix the problem of not being able to paste image in editor (#9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR rectifies the wrong use of SimpleFilePart. We should use the interface FilePart instead. /kind bug Fixes #8 ```release-note 修复无法在编辑器中粘贴图片的问题 ``` --- .../run/halo/alist/endpoint/AListAttachmentHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java b/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java index c967823..32f6781 100644 --- a/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java +++ b/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java @@ -44,7 +44,6 @@ import run.halo.app.core.extension.attachment.Constant; import run.halo.app.core.extension.attachment.Policy; import run.halo.app.core.extension.attachment.endpoint.AttachmentHandler; -import run.halo.app.core.extension.attachment.endpoint.SimpleFilePart; import run.halo.app.extension.ConfigMap; import run.halo.app.extension.Metadata; import run.halo.app.extension.ReactiveExtensionClient; @@ -122,9 +121,10 @@ public Mono upload(UploadContext uploadContext) { Map.of(Constant.EXTERNAL_LINK_ANNO_KEY, "")); var spec = new Attachment.AttachmentSpec(); - SimpleFilePart simpleFilePart = (SimpleFilePart) file; - spec.setDisplayName(simpleFilePart.filename()); - spec.setMediaType(simpleFilePart.mediaType().toString()); + spec.setDisplayName(file.filename()); + Optional.ofNullable(file.headers().getContentType()) + .map(Objects::toString) + .ifPresent(spec::setMediaType); spec.setSize(fileSize); var attachment = new Attachment();