You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.0 KiB
2.0 KiB
title | description |
---|---|
附件存储 | 为附件存储方式提供的扩展点,可用于自定义附件存储方式。 |
附件存储策略扩展点支持扩展附件的上传和存储方式,如将附件存储到第三方云存储服务中。
扩展点接口如下:
public interface AttachmentHandler extends ExtensionPoint {
Mono<Attachment> upload(UploadContext context);
Mono<Attachment> delete(DeleteContext context);
default Mono<URI> getSharedURL(Attachment attachment,
Policy policy,
ConfigMap configMap,
Duration ttl) {
return Mono.empty();
}
default Mono<URI> getPermalink(Attachment attachment,
Policy policy,
ConfigMap configMap) {
return Mono.empty();
}
upload
方法用于上传附件,返回值为Mono<Attachment>
,其中Attachment
为上传成功后的附件对象。delete
方法用于删除附件,返回值为Mono<Attachment>
,其中Attachment
为删除后的附件对象。getSharedURL
方法用于获取附件的共享链接,返回值为Mono<URI>
,其中URI
为附件的共享链接。getPermalink
方法用于获取附件的永久链接,返回值为Mono<URI>
,其中URI
为附件的永久链接。
AttachmentHandler
对应的 ExtensionPointDefinition
如下:
apiVersion: plugin.halo.run/v1alpha1
kind: ExtensionPointDefinition
metadata:
name: attachment-handler
spec:
className: run.halo.app.core.extension.attachment.endpoint.AttachmentHandler
displayName: AttachmentHandler
type: MULTI_INSTANCE
description: "Provide extension points for attachment storage strategies"
即声明 ExtensionDefinition
自定义模型对象时对应的 extensionPointName
为 attachment-handler
。
可以参考以下项目示例: