Skip to content

Commit

Permalink
Fix the problem of not being able to paste image in editor (#9)
Browse files Browse the repository at this point in the history
This PR rectifies the wrong use of SimpleFilePart. We should use the interface FilePart instead.

/kind bug

Fixes #8 

```release-note
修复无法在编辑器中粘贴图片的问题
```
  • Loading branch information
JohnNiang authored Aug 13, 2024
1 parent ec2ad22 commit 6a39426
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,9 +121,10 @@ public Mono<Attachment> 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();
Expand Down

0 comments on commit 6a39426

Please sign in to comment.