Merge pull request #979 from trheyi/main
Enhance asset upload management in neo package
This commit is contained in:
commit
d2c1e58c5c
3 changed files with 18 additions and 1 deletions
|
|
@ -41,7 +41,7 @@ func RegisterDefault(name string) (*Manager, error) {
|
||||||
|
|
||||||
option := ManagerOption{
|
option := ManagerOption{
|
||||||
Driver: "local",
|
Driver: "local",
|
||||||
Options: map[string]interface{}{"path": filepath.Join(config.Conf.DataRoot, "attachments")},
|
Options: map[string]interface{}{"path": filepath.Join(config.Conf.DataRoot, name)},
|
||||||
MaxSize: "50M",
|
MaxSize: "50M",
|
||||||
ChunkSize: "2M",
|
ChunkSize: "2M",
|
||||||
AllowedTypes: []string{
|
AllowedTypes: []string{
|
||||||
|
|
|
||||||
16
neo/load.go
16
neo/load.go
|
|
@ -148,6 +148,22 @@ func initUpload() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the chat upload setting for asset upload, if the asset upload setting is not set. (public assets)
|
||||||
|
if Neo.UploadSetting.Assets == nil {
|
||||||
|
_, err := attachment.RegisterDefault("assets")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use custom asset upload setting
|
||||||
|
if Neo.UploadSetting.Assets != nil {
|
||||||
|
Neo.UploadSetting.Assets.ReplaceEnv(config.Conf.DataRoot)
|
||||||
|
_, err := attachment.Register("assets", Neo.UploadSetting.Assets.Driver, *Neo.UploadSetting.Assets)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ type AuthFields struct {
|
||||||
// ===============================
|
// ===============================
|
||||||
type Upload struct {
|
type Upload struct {
|
||||||
Chat *attachment.ManagerOption `json:"chat,omitempty" yaml:"chat,omitempty"` // Chat conversation upload setting, if not set use the local and root path is `/attachments`.
|
Chat *attachment.ManagerOption `json:"chat,omitempty" yaml:"chat,omitempty"` // Chat conversation upload setting, if not set use the local and root path is `/attachments`.
|
||||||
|
Assets *attachment.ManagerOption `json:"assets,omitempty" yaml:"assets,omitempty"` // Asset upload setting, if not set use the chat upload setting.
|
||||||
Knowledge *attachment.ManagerOption `json:"knowledge,omitempty" yaml:"knowledge,omitempty"` // Knowledge base upload setting, if not set use the chat upload setting.
|
Knowledge *attachment.ManagerOption `json:"knowledge,omitempty" yaml:"knowledge,omitempty"` // Knowledge base upload setting, if not set use the chat upload setting.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue