Files
new-api/service/task_artifact_store.go
CaIon 14a9acd368 feat(custom): CNY native billing, daily check-in button, subscription plans page, usage docs and promo banner
Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed).

- CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels
- New CheckinButton in both authenticated and public headers (Turnstile supported)
- New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset
- New /docs 12-section beginner guide with anchor navigation
- New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi)
- README: document custom features, live demo https://ai.88531.cn
2026-09-23 16:28:52 +08:00

64 lines
1.9 KiB
Go

package service
import (
"context"
"errors"
"io"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/setting/system_setting"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
)
// StoredArtifactRef describes a persisted artifact object. No reference is
// produced until a concrete storage backend is implemented.
type StoredArtifactRef struct {
Backend string
Bucket string
ObjectKey string
MimeType string
Size int64
}
// TaskArtifactStore is the persistence boundary for generated artifact bytes.
// types.TaskArtifact is re-exported by relay/channel as channel.TaskArtifact.
type TaskArtifactStore interface {
Enabled() bool
Resolve(task *model.Task, artifactKey string) (*StoredArtifactRef, error)
Persist(ctx context.Context, task *model.Task, artifact types.TaskArtifact, content io.Reader) (*StoredArtifactRef, error)
Serve(c *gin.Context, task *model.Task, ref *StoredArtifactRef) error
}
var ErrTaskArtifactStoreDisabled = errors.New("task artifact store is disabled")
type disabledArtifactStore struct{}
func (disabledArtifactStore) Enabled() bool {
return false
}
func (disabledArtifactStore) Resolve(*model.Task, string) (*StoredArtifactRef, error) {
return nil, nil
}
func (disabledArtifactStore) Persist(context.Context, *model.Task, types.TaskArtifact, io.Reader) (*StoredArtifactRef, error) {
return nil, ErrTaskArtifactStoreDisabled
}
func (disabledArtifactStore) Serve(*gin.Context, *model.Task, *StoredArtifactRef) error {
return ErrTaskArtifactStoreDisabled
}
var taskArtifactStore TaskArtifactStore = &disabledArtifactStore{}
func init() {
_ = system_setting.LoadTaskArtifactStoreConfig()
}
// GetTaskArtifactStore returns the process-wide artifact storage backend. This
// release always returns the disabled implementation.
func GetTaskArtifactStore() TaskArtifactStore {
return taskArtifactStore
}