Versions in this module Expand all Collapse all v1 v1.0.10 Sep 21, 2019 Changes in this version + func RandomWithMD5(length uint) string v1.0.9 Sep 19, 2019 v1.0.8 Sep 19, 2019 v1.0.7 Sep 18, 2019 v1.0.6 Sep 17, 2019 v1.0.5 Sep 16, 2019 v1.0.4 Sep 16, 2019 v1.0.3 Sep 16, 2019 v1.0.2 Sep 16, 2019 v1.0.1 Sep 14, 2019 v1.0.0 Sep 13, 2019 Changes in this version + const ChunkSize + const Hidden + const IsDir + const SecretLength + const TokenNonReadOnly + const TokenReadOnly + var ErrAccessDenied = errors.New("file can't be accessed by some tokens") + var ErrAppendToDir = errors.New("can't append data to directory") + var ErrChunkExceedLimit = fmt.Errorf("total length exceed limit: %d bytes", ChunkSize) + var ErrDeleteNonEmptyDir = errors.New("delete non-empty directory") + var ErrFileExisted = errors.New("file has already existed") + var ErrInvalidChunkID = errors.New("invalid chunk id") + var ErrInvalidObject = errors.New("invalid object") + var ErrInvalidSeekWhence = errors.New("invalid seek whence") + var ErrNegativePosition = errors.New("negative read position") + var ErrObjectNoChunks = errors.New("object has no any chunks") + var ErrOverwriteDir = errors.New("directory can't be overwritten") + var ErrReadDir = errors.New("can't read a directory") + var NewAppForTest = newAppForTest + var NewArbitrarilyTokenForTest = newArbitrarilyTokenForTest + var NewTempDirForTest = newTempDirForTest + var NewTokenForTest = newTokenForTest + var SetUpTestCaseWithTrx = setUpTestCaseWithTrx + func CountObjectChunkByChunkID(chunkID uint64, db *gorm.DB) (int, error) + func DeleteAppByUIDPermanently(uid string, db *gorm.DB) error + func DeleteAppByUIDSoft(uid string, db *gorm.DB) error + func DeleteAppPermanently(app *App, db *gorm.DB) error + func DeleteAppSoft(app *App, db *gorm.DB) error + func NewObjectReader(object *Object, rootPath *string, db *gorm.DB) (io.ReadSeeker, error) + func NewSecret() string + func Random(length uint) []byte + func RandomWithMd5(length uint) string + func UID() string + type App struct + CreatedAt time.Time + DeletedAt *time.Time + ID uint64 + Name string + Note *string + Secret string + UID string + UpdatedAt time.Time + func FindAppByUID(uid string, db *gorm.DB) (*App, error) + func FindAppByUIDWithTrashed(uid string, db *gorm.DB) (*App, error) + func NewApp(name string, note *string, db *gorm.DB) (*App, error) + func (app *App) AfterCreate(tx *gorm.DB) error + func (app *App) TableName() string + type Chunk struct + CreatedAt time.Time + Hash string + ID uint64 + Size int + UpdatedAt time.Time + func CreateChunkFromBytes(p []byte, rootPath *string, db *gorm.DB) (chunk *Chunk, err error) + func CreateEmptyContentChunk(rootPath *string, db *gorm.DB) (chunk *Chunk, err error) + func FindChunkByHash(h string, db *gorm.DB) (*Chunk, error) + func (c *Chunk) AppendBytes(p []byte, rootPath *string, db *gorm.DB) (chunk *Chunk, writeCount int, err error) + func (c *Chunk) Reader(rootPath *string) (file *os.File, err error) + func (c Chunk) Path(rootPath *string) (path string, err error) + func (c Chunk) TableName() string + type Down = func(*testing.T) + type File struct + App App + AppID uint64 + Children []File + CreatedAt time.Time + DeletedAt *time.Time + DownloadCount uint64 + Ext string + Hidden int8 + Histories []History + ID uint64 + IsDir int8 + Name string + Object Object + ObjectID uint64 + PID uint64 + Parent *File + Size int + UID string + UpdatedAt time.Time + func CreateFileFromReader(app *App, savePath string, reader io.Reader, hidden int8, rootPath *string, ...) (file *File, err error) + func CreateOrGetLastDirectory(app *App, dirPath string, db *gorm.DB) (*File, error) + func CreateOrGetRootPath(app *App, db *gorm.DB) (*File, error) + func FindFileByPath(app *App, path string, db *gorm.DB, useCache bool) (*File, error) + func FindFileByPathWithTrashed(app *App, path string, db *gorm.DB) (*File, error) + func FindFileByUID(uid string, trashed bool, db *gorm.DB) (*File, error) + func (f *File) AppendFromReader(reader io.Reader, hidden int8, rootPath *string, db *gorm.DB) (err error) + func (f *File) CanBeAccessedByToken(token *Token, db *gorm.DB) error + func (f *File) Delete(forceDelete bool, db *gorm.DB) (err error) + func (f *File) MoveTo(newPath string, db *gorm.DB) (err error) + func (f *File) OverWriteFromReader(reader io.Reader, hidden int8, rootPath *string, db *gorm.DB) (err error) + func (f *File) Path(db *gorm.DB) (string, error) + func (f *File) Reader(rootPath *string, db *gorm.DB) (io.ReadSeeker, error) + func (f *File) TableName() string + func (f *File) UpdateParentSize(size int, db *gorm.DB) error + type History struct + CreatedAt time.Time + FileID uint64 + ID uint64 + ObjectID uint64 + Path string + func (h *History) TableName() string + type Object struct + Chunks []Chunk + CreatedAt time.Time + Files []File + Hash string + Histories []History + ID uint64 + ObjectChunks []ObjectChunk + Size int + UpdatedAt time.Time + func CreateEmptyObject(rootPath *string, db *gorm.DB) (*Object, error) + func CreateObjectFromReader(reader io.Reader, rootPath *string, db *gorm.DB) (*Object, error) + func FindObjectByHash(h string, db *gorm.DB) (*Object, error) + func (o *Object) AppendFromReader(reader io.Reader, rootPath *string, db *gorm.DB) (*Object, int, error) + func (o *Object) ChunkCount(db *gorm.DB) int + func (o *Object) ChunkWithNumber(number int, db *gorm.DB) (chunk *Chunk, err error) + func (o *Object) FileCountWithTrashed(db *gorm.DB) int + func (o *Object) LastChunk(db *gorm.DB) (*Chunk, error) + func (o *Object) LastChunkNumber(db *gorm.DB) (int, error) + func (o *Object) LastObjectChunk(db *gorm.DB) (*ObjectChunk, error) + func (o *Object) Reader(rootPath *string, db *gorm.DB) (io.ReadSeeker, error) + func (o Object) TableName() string + type ObjectChunk struct + Chunk Chunk + ChunkID uint64 + CreatedAt time.Time + HashState *string + ID uint64 + Number int + Object Object + ObjectID uint64 + UpdatedAt time.Time + func (oc ObjectChunk) TableName() string + type Request struct + AppID *uint64 + CreatedAt time.Time + ID uint64 + IP *string + Method *string + Nonce *string + Protocol string + RequestBody string + RequestHeader string + ResponseBody string + ResponseCode int + Service *string + Token *string + func FindRequestWithAppAndNonce(app *App, nonce string, db *gorm.DB) (*Request, error) + func MustNewHTTPRequest(ip, method, url string, db *gorm.DB) *Request + func MustNewRequestWithProtocol(protocol string, db *gorm.DB) *Request + func NewRequestWithProtocol(protocol string, db *gorm.DB) (*Request, error) + func (r *Request) Save(db *gorm.DB) error + type Token struct + App App + AppID uint64 + AvailableTimes int + CreatedAt time.Time + DeletedAt *time.Time + ExpiredAt *time.Time + ID uint64 + IP *string + Path string + ReadOnly int8 + Secret *string + UID string + UpdatedAt time.Time + func FindTokenByUID(uid string, db *gorm.DB) (*Token, error) + func FindTokenByUIDWithTrashed(uid string, db *gorm.DB) (*Token, error) + func NewToken(app *App, path string, expiredAt *time.Time, ip, secret *string, ...) (*Token, error) + func (t *Token) AllowIPAccess(ip string) bool + func (t *Token) BeforeSave() (err error) + func (t *Token) PathWithScope(path string) string + func (t *Token) Scope() string + func (t *Token) TableName() string + func (t *Token) UpdateAvailableTimes(inc int, db *gorm.DB) error