Documentation
¶
Index ¶
- Constants
- func CheckImageType(filename string) (string, error)
- func CountDailyUploads(userId uint64) int64
- func CountUserUploadsInTimeRange(userId uint64, startTime, endTime time.Time) int64
- func CountUserUploadsToday(userId uint64) int64
- func DeleteByName(name string) error
- func DeleteByNameContext(ctx context.Context, name string) error
- func UpdateFileContent(ctx context.Context, name string, data []byte) error
- type Entity
- func CreateFileMetadata(ctx context.Context, userId uint64, name string, fileType string, size int64, ...) (*Entity, error)
- func GetByName(name string) (entity Entity)
- func GetFileByName(name string) (*Entity, error)
- func GetFileByNameContext(ctx context.Context, name string) (*Entity, error)
- func GetFileMetadataByName(name string) (*Entity, error)
- func GetFileMetadataByNameContext(ctx context.Context, name string) (*Entity, error)
- func GetPendingFileMetadataByNameContext(ctx context.Context, name string) (*Entity, error)
- func ListPendingFilesBefore(ctx context.Context, before time.Time, limit int) ([]Entity, error)
- func MarkFileReady(ctx context.Context, name string) (*Entity, error)
- func SaveFile(userId uint64, name string, fileType string, data []byte) (*Entity, error)
- type FileResource
- type FileResourcePageResult
Constants ¶
View Source
const ( StorageStatusPending = "pending" StorageStatusReady = "ready" )
Variables ¶
This section is empty.
Functions ¶
func CheckImageType ¶
CheckImageType returns the image MIME type for supported extensions.
func CountDailyUploads ¶ added in v0.1.1
CountDailyUploads returns the number of files uploaded by a user today.
func CountUserUploadsInTimeRange ¶ added in v0.0.6
CountUserUploadsInTimeRange counts uploads for a user within a time range.
func CountUserUploadsToday ¶ added in v0.0.6
CountUserUploadsToday counts uploads for a user today.
func DeleteByName ¶ added in v0.2.61
func DeleteByNameContext ¶ added in v0.2.62
Types ¶
type Entity ¶
type Entity struct {
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` // 主键
Name string `gorm:"column:name;uniqueIndex;type:varchar(256);not null;" json:"name"` // 添加唯一索引
Type string `gorm:"column:assert_type;index;type:varchar(64);not null;" json:"type"` //
Data []byte `gorm:"column:content;type:BLOB;" json:"data"` // 内容
Size int64 `gorm:"column:file_size;type:bigint;not null;default:0;" json:"size"`
StorageDriver string `gorm:"column:storage_driver;type:varchar(32);not null;default:database;" json:"storageDriver"`
StorageStatus string `gorm:"column:storage_status;type:varchar(16);not null;default:ready;index;" json:"storageStatus"`
UserId uint64 `` //
/* 126-byte string literal not displayed */
CreatedAt time.Time `gorm:"column:created_at;index;autoCreateTime;<-:create;index:idx_file_data_user_created,priority:2;" json:"createdAt"` //
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
}
func CreateFileMetadata ¶ added in v0.2.62
func GetFileByName ¶
func GetFileByNameContext ¶ added in v0.2.62
func GetFileMetadataByName ¶ added in v0.2.61
func GetFileMetadataByNameContext ¶ added in v0.2.62
func GetPendingFileMetadataByNameContext ¶ added in v0.2.62
func ListPendingFilesBefore ¶ added in v0.2.62
func MarkFileReady ¶ added in v0.2.62
func (*Entity) GetAccessPath ¶ added in v0.0.6
type FileResource ¶ added in v0.2.46
type FileResource struct {
Id uint64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Size int64 `json:"size"`
UserId uint64 `json:"userId"`
CreatedAt time.Time `json:"createdAt"`
URL string `json:"url"`
Data []byte `json:"-"`
}
func (FileResource) GetAccessPath ¶ added in v0.2.46
func (itself FileResource) GetAccessPath() string
type FileResourcePageResult ¶ added in v0.2.46
type FileResourcePageResult struct {
List []FileResource
Page int
PageSize int
Total int64
}
func FileResourcePage ¶ added in v0.2.46
func FileResourcePage(page, pageSize int) FileResourcePageResult
Click to show internal directories.
Click to hide internal directories.