From eddbf10f8bf7b319baea34ab41d52faa21532785 Mon Sep 17 00:00:00 2001 From: LIlGG <1103069291@qq.com> Date: Wed, 21 Aug 2024 17:14:16 +0800 Subject: [PATCH] update upload-from-url role resource --- .../extension/service/impl/DefaultAttachmentService.java | 5 +---- .../main/resources/extensions/role-template-attachment.yaml | 6 ++++-- .../main/resources/extensions/role-template-uc-content.yaml | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/application/src/main/java/run/halo/app/core/extension/service/impl/DefaultAttachmentService.java b/application/src/main/java/run/halo/app/core/extension/service/impl/DefaultAttachmentService.java index 212d1ec98c..08cc61f8a1 100644 --- a/application/src/main/java/run/halo/app/core/extension/service/impl/DefaultAttachmentService.java +++ b/application/src/main/java/run/halo/app/core/extension/service/impl/DefaultAttachmentService.java @@ -143,7 +143,6 @@ public Mono getSharedURL(Attachment attachment, Duration ttl) { @Override public Mono uploadFromUrl(@NonNull URL url, @NonNull String policyName, String groupName, String filename) { - // TODO validate url var uri = URI.create(url.toString()); AtomicReference mediaTypeRef = new AtomicReference<>(); AtomicReference fileNameRef = new AtomicReference<>(filename); @@ -176,9 +175,7 @@ private static String getExternalUrlFilename(URI externalUrl, HttpHeaders httpHe var path = externalUrl.getPath(); fileName = Paths.get(path).getFileName().toString(); } - if (!FileNameUtils.hasFileExtension(fileName)) { - // TODO get file extension from media type - } + // TODO get file extension from media type return fileName; } diff --git a/application/src/main/resources/extensions/role-template-attachment.yaml b/application/src/main/resources/extensions/role-template-attachment.yaml index 08ea09bb72..a32e6db9db 100644 --- a/application/src/main/resources/extensions/role-template-attachment.yaml +++ b/application/src/main/resources/extensions/role-template-attachment.yaml @@ -17,12 +17,14 @@ rules: - apiGroups: [ "api.console.halo.run" ] resources: [ "attachments" ] verbs: [ "*" ] + - apiGroups: [ "api.console.halo.run" ] + resources: [ "attachments/upload-from-url" ] + verbs: [ "create" ] - apiGroups: [ "" ] resources: [ "settings" ] verbs: [ "get" ] - nonResourceURLs: [ - "/apis/api.console.halo.run/v1alpha1/attachments/upload", - "/apis/api.console.halo.run/v1alpha1/attachments/-/upload-from-url" + "/apis/api.console.halo.run/v1alpha1/attachments/upload" ] verbs: [ "create" ] --- diff --git a/application/src/main/resources/extensions/role-template-uc-content.yaml b/application/src/main/resources/extensions/role-template-uc-content.yaml index b876b843d7..93f7bcd6b4 100644 --- a/application/src/main/resources/extensions/role-template-uc-content.yaml +++ b/application/src/main/resources/extensions/role-template-uc-content.yaml @@ -114,6 +114,6 @@ rules: - apiGroups: [ "uc.api.content.halo.run" ] resources: [ "attachments" ] verbs: [ "create", "update", "delete" ] - - nonResourceURLs: [ - "/apis/api.console.halo.run/v1alpha1/attachments/-/upload-from-url" - ] + - apiGroups: [ "uc.api.content.halo.run" ] + resources: [ "attachments/upload-from-url" ] + verbs: [ "create" ]