alist/internal/model/object.go
okatu-loli a2be86c7c6 feat(storage): Support for displaying file storage classes
Adds storage class information to file metadata and API responses.

This change introduces the ability to store file storage classes in file metadata and display them in API responses. This allows users to view a file's storage tier (e.g., S3 Standard, Glacier), enhancing data management capabilities.

Implementation details include:
- Introducing the StorageClassProvider interface and the ObjWrapStorageClass structure to uniformly handle and communicate object storage class information.
- Updated file metadata structures (e.g., ArchiveObj, FileInfo, RespFile) to include a StorageClass field.
- Modified relevant API response functions (e.g., GetFileInfo, GetFileList) to populate and return storage classes.
- Integrated functionality for retrieving object storage classes from underlying storage systems (e.g., S3) and wrapping them in lists.
2025-10-15 15:59:55 +08:00

121 lines
1.6 KiB
Go

package model
import (
"time"
"github.com/alist-org/alist/v3/pkg/utils"
)
type ObjWrapName struct {
Name string
Obj
}
type ObjWrapStorageClass struct {
storageClass string
Obj
}
func (o *ObjWrapName) Unwrap() Obj {
return o.Obj
}
func (o *ObjWrapName) GetName() string {
return o.Name
}
func (o *ObjWrapStorageClass) Unwrap() Obj {
return o.Obj
}
func (o *ObjWrapStorageClass) StorageClass() string {
return o.storageClass
}
func (o *ObjWrapStorageClass) SetPath(path string) {
if setter, ok := o.Obj.(SetPath); ok {
setter.SetPath(path)
}
}
type Object struct {
ID string
Path string
Name string
Size int64
Modified time.Time
Ctime time.Time // file create time
IsFolder bool
HashInfo utils.HashInfo
}
func (o *Object) GetName() string {
return o.Name
}
func (o *Object) GetSize() int64 {
return o.Size
}
func (o *Object) ModTime() time.Time {
return o.Modified
}
func (o *Object) CreateTime() time.Time {
if o.Ctime.IsZero() {
return o.ModTime()
}
return o.Ctime
}
func (o *Object) IsDir() bool {
return o.IsFolder
}
func (o *Object) GetID() string {
return o.ID
}
func (o *Object) GetPath() string {
return o.Path
}
func (o *Object) SetPath(path string) {
o.Path = path
}
func (o *Object) GetHash() utils.HashInfo {
return o.HashInfo
}
type Thumbnail struct {
Thumbnail string
}
type Url struct {
Url string
}
func (w Url) URL() string {
return w.Url
}
func (t Thumbnail) Thumb() string {
return t.Thumbnail
}
type ObjThumb struct {
Object
Thumbnail
}
type ObjectURL struct {
Object
Url
}
type ObjThumbURL struct {
Object
Thumbnail
Url
}