Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFileNotFound = &errors.DomainError{Code: "FILE_NOT_FOUND", Message: "文件不存在"} ErrFileNameEmpty = &errors.DomainError{Code: "FILE_NAME_EMPTY", Message: "文件名不能为空"} ErrFileIDEmpty = &errors.DomainError{Code: "FILE_NAME_EMPTY", Message: "文件ID不能为空"} ErrFilePathEmpty = &errors.DomainError{Code: "FILE_PATH_EMPTY", Message: "文件路径不能为空"} ErrFileQueryFailed = &errors.DomainError{Code: "FILE_QUERY_FAILED", Message: "文件查询失败"} ErrFileNameExists = &errors.DomainError{Code: "FILE_NAME_EXISTS", Message: "已存在同名文件"} ErrFileDeleteFailed = &errors.DomainError{Code: "FILE_DELETE_FAILED", Message: "文件删除失败"} )
文件管理相关错误
View Source
var ( // ErrFileUploadFailed 基础上传错误 ErrFileUploadFailed = &errors.DomainError{Code: "FILE_UPLOAD_FAILED", Message: "文件上传失败"} ErrFileCheckFailed = &errors.DomainError{Code: "FILE_CHECK_FAILED", Message: "文件检测失败"} // ErrMultipartInitFailed 分片上传相关错误 ErrMultipartInitFailed = &errors.DomainError{Code: "MULTIPART_INIT_FAILED", Message: "分片上传初始化失败"} ErrMultipartUploadFailed = &errors.DomainError{Code: "MULTIPART_UPLOAD_FAILED", Message: "分片上传失败"} ErrMultipartCompleteFailed = &errors.DomainError{Code: "MULTIPART_COMPLETE_FAILED", Message: "分片上传完成失败"} ErrMultipartStatusFailed = &errors.DomainError{Code: "MULTIPART_STATUS_FAILED", Message: "分片上传状态查询失败"} ErrMultipartReadFailed = &errors.DomainError{Code: "MULTIPART_READ_FAILED", Message: "文件分片读取失败"} // ErrFileInvalidType 文件类型和限制相关错误 ErrFileInvalidType = &errors.DomainError{Code: "FILE_INVALID_TYPE", Message: "不支持的文件类型"} ErrFileSizeExceeded = &errors.DomainError{Code: "FILE_SIZE_EXCEEDED", Message: "文件大小超出限制"} // ErrFileRecordSaveFailed 存储相关错误 ErrFileRecordSaveFailed = &errors.DomainError{Code: "FILE_RECORD_SAVE_FAILED", Message: "文件记录保存失败"} )
文件上传相关错误
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
ID uint64 `json:"id"`
MediaType MediaType `json:"media_type"`
Name FileName `json:"name"`
NameIndex string `json:"name_index"`
Path string `json:"path"`
Size uint64 `json:"size"`
Ext string `json:"ext"`
MimeType string `json:"mime_type"`
Status uint8 `json:"status"`
CreatedAt time.Time `json:"created_at"`
}
File 文件领域模型
type MediaType ¶
type MediaType uint8
MediaType 文件媒体类型
func DetermineMediaType ¶
DetermineMediaType 根据扩展名和MIME类型确定媒体类型
type MultipartUpload ¶
type MultipartUpload struct {
ID uint64 `json:"id"`
FileName string `json:"file_name"`
Path string `json:"path"`
Size uint64 `json:"size"`
MimeType string `json:"mime_type"`
Ext string `json:"ext"`
UploadID string `json:"upload_id"`
Status uint8 `json:"status"` // 1-进行中 2-已完成 3-已取消
Parts []*Part `json:"parts"`
CreatedAt time.Time `json:"created_at"`
}
MultipartUpload 分片上传信息
func MultipartUploadFormModel ¶
func MultipartUploadFormModel(mu *file.MultipartUpload) *MultipartUpload
func NewMultipartUpload ¶
func NewMultipartUpload(fileName, path string, size uint64, mimeType, ext, uploadId string) *MultipartUpload
NewMultipartUpload 创建分片上传
type Part ¶
Part 分片信息
func PartListFromStoragePart ¶
func PartListFromStoragePart(parts []fs.MultipartPart) []Part
Click to show internal directories.
Click to hide internal directories.