Documentation
¶
Index ¶
- Constants
- Variables
- func DirExists(path string) bool
- func GetDefaultConfig() string
- func GroupArrToStringArr(groups []Group) []string
- func IsDefaultPreview(pt PreviewType) bool
- func IsImagePreview(pt PreviewType) bool
- func IsTextPreview(pt PreviewType) bool
- func IsVideoPreview(pt PreviewType) bool
- func ShredderFile(localFile string, size int64)
- func TagArrToStringArr(tags []Tag) []string
- type BulkPublishResponse
- type Config
- func (config *Config) Check() bool
- func (config Config) GetDefaultRole() *Role
- func (config Config) GetHTMLFile(fileName string) string
- func (config Config) GetStaticFile(fileName string) string
- func (config Config) GetStorageFile(fileName string) string
- func (config Config) GetTemplateFile(fileName string) string
- func (config Config) IsRawUseragent(agent string) bool
- type CountResponse
- type CredentialsRequest
- type File
- func (file *File) AddGroups(db *gorm.DB, groupsToAdd []string, user *User) error
- func (file *File) AddTags(db *gorm.DB, tagsToAdd []string, user *User) error
- func (file *File) Delete(db *gorm.DB, config *Config) error
- func (file File) GetAttributes() FileAttributes
- func (file File) GetCount(db *gorm.DB, fileID uint) (uint, error)
- func (file File) GetNamespace() *Namespace
- func (file *File) GetPublicNameWithExtension() string
- func (file File) HasGroup(sGroup string) bool
- func (file File) HasTag(sTag string) bool
- func (file *File) Insert(db *gorm.DB, user *User) error
- func (file File) IsInGroupList(groups []string) bool
- func (file File) IsInTagList(tags []string) bool
- func (file *File) Publish(db *gorm.DB, publicName string) (bool, error)
- func (file *File) RemoveGroups(db *gorm.DB, groupsToRemove []string) error
- func (file *File) RemoveTags(db *gorm.DB, tagsToRemove []string) error
- func (file *File) Rename(db *gorm.DB, newName string) error
- func (file *File) Save(db *gorm.DB) error
- func (file *File) SetEncryption(encription string) *File
- func (file *File) SetUniqueFilename(db *gorm.DB) bool
- func (file *File) SetVilibility(db *gorm.DB, newVisibility bool) error
- func (file *File) UpdateNamespace(db *gorm.DB, newNamespace *Namespace, user *User) error
- type FileAttributes
- type FileListRequest
- type FileRequest
- type FileResponseItem
- type FileUpdateItem
- type Group
- func FindGroup(db *gorm.DB, name string, namespace *Namespace, user *User) (*Group, error)
- func FindGroups(db *gorm.DB, sGroups []string, namespace *Namespace) []Group
- func GetGroup(db *gorm.DB, name string, namespace *Namespace, user *User) *Group
- func GroupsFromStringArr(arr []string, namespace Namespace, user *User) []Group
- type IDsResponse
- type ListFileResponse
- type LoginResponse
- type LoginSession
- type Namespace
- type NamespaceRequest
- type Namespaceinfo
- type OptionalRequetsParameter
- type Permission
- type PingRequest
- type PreviewTemplate
- type PreviewType
- type PublishResponse
- type ResponseStatus
- type Role
- type StringResponse
- type StringSliceResponse
- type Tag
- func FindTag(db *gorm.DB, name string, namespace *Namespace, user *User) (*Tag, error)
- func FindTags(db *gorm.DB, sTags []string, namespace *Namespace) []Tag
- func GetTag(db *gorm.DB, name string, namespace *Namespace, user *User) *Tag
- func TagsFromStringArr(arr []string, namespace Namespace, user *User) []Tag
- type UpdateAttributeRequest
- type UploadRequest
- type UploadResponse
- type UploadType
- type User
- func (user User) AllowedToUploadURLs() bool
- func (user User) CanCreateNamespaces() bool
- func (user User) CanReadForeignNamespace() bool
- func (user User) CanUploadFiles() bool
- func (user User) CanWriteForeignNamespace() bool
- func (user *User) CreateDefaultNamespace(db *gorm.DB) (*Namespace, error)
- func (user *User) GetAllGroups(db *gorm.DB) ([]Group, error)
- func (user *User) GetDefaultNamespaceName() string
- func (user *User) GetNamespaceName(namespace string) string
- func (user *User) GetUsername() string
- func (user *User) Has(db *gorm.DB, checkPass bool) (bool, error)
- func (user *User) HasAccess(namespace *Namespace) bool
- func (user User) HasUploadLimit() bool
- func (user *User) Login(db *gorm.DB, machineID string) (*LoginSession, error)
- func (user User) Register(db *gorm.DB, config *Config) error
- type UserAttributeDataResponse
- type UserAttributesRequest
Constants ¶
const ( // NotFoundError error from server NotFoundError string = "Not found" // ActionNotAllowed error from server ActionNotAllowed string = "Action not allowed" // WrongLength error from server WrongLength string = "Wrong length" // ServerError error from server ServerError string = "Server Error" // WrongInputFormatError wrong user input WrongInputFormatError string = "Wrong inputFormat!" // InvalidTokenError token is not valid InvalidTokenError string = "Token not valid" // InvalidCallbackURL token is not valid InvalidCallbackURL string = "Callback url is invalid" // BatchSizeTooLarge batch is too large BatchSizeTooLarge string = "BatchSize soo large!" // WrongIntegerFormat integer is probably no integer WrongIntegerFormat string = "Number is string" // MultipleSourceNameErr err name already exists MultipleSourceNameErr string = "You can't have multiple sources with the same name" // UserIsInvalidErr err if user is invalid UserIsInvalidErr string = "user is invalid" )
const ( // HeaderStatus headername for status in response HeaderStatus string = "X-Response-Status" // HeaderStatusMessage headername for status in response HeaderStatusMessage string = "X-Response-Message" // HeaderContentType contenttype of response HeaderContentType string = "Content-Type" // HeaderFileName filename header HeaderFileName string = "X-Filename" // HeaderFileID fileid header HeaderFileID string = "X-FileID" // HeaderEncryption encryption header HeaderEncryption string = "X-Encryption" // HeaderRequest request content HeaderRequest string = "Request" // HeaderContentLength request content length HeaderContentLength string = "ContentLength" // HeaderChecksum files checksum HeaderChecksum string = "Checksum" )
const SessionTokenLength = 64
SessionTokenLength length of session token
Variables ¶
var ErrorUserAlreadyExists = errors.New("user already exists")
ErrorUserAlreadyExists error if user exists
var PreviewMimes map[PreviewType][]string = map[PreviewType][]string{
ImagePreviewType: {
"image/*",
},
VideoPreviewType: {
"video/*",
},
TextPreviewType: {
"text/*",
},
}
PreviewMimes mimes assigned to preview
Functions ¶
func GetDefaultConfig ¶
func GetDefaultConfig() string
GetDefaultConfig gets the default config path
func GroupArrToStringArr ¶
GroupArrToStringArr return string arr from group
func IsDefaultPreview ¶
func IsDefaultPreview(pt PreviewType) bool
IsDefaultPreview return true if pt is default previewtype
func IsImagePreview ¶
func IsImagePreview(pt PreviewType) bool
IsImagePreview return true if pt is image previewtype
func IsTextPreview ¶
func IsTextPreview(pt PreviewType) bool
IsTextPreview return true if pt is text previewtype
func IsVideoPreview ¶ added in v1.1.0
func IsVideoPreview(pt PreviewType) bool
IsVideoPreview return true if pt is video previewtype
func TagArrToStringArr ¶
TagArrToStringArr return string arr from tags
Types ¶
type BulkPublishResponse ¶
type BulkPublishResponse struct {
Files []UploadResponse `json:"files"`
}
BulkPublishResponse response for publishing a file
type Config ¶
type Config struct {
Server configServer
Webserver webserverConf
}
Config config for the server
func InitConfig ¶
InitConfig inits the config Returns true if system should exit
func (Config) GetDefaultRole ¶
GetDefaultRole return the path and file for an uploaded file
func (Config) GetHTMLFile ¶
GetHTMLFile return path of html file
func (Config) GetStaticFile ¶
GetStaticFile return path of html file
func (Config) GetStorageFile ¶
GetStorageFile return the path and file for an uploaded file
func (Config) GetTemplateFile ¶
GetTemplateFile return path of html file
func (Config) IsRawUseragent ¶
IsRawUseragent return true if file should be raw depending on useragent
type CountResponse ¶
type CountResponse struct {
Count uint32 `json:"count"`
}
CountResponse response containing a count of changed items
type CredentialsRequest ¶
type CredentialsRequest struct {
MachineID string `json:"mid,omitempty"`
Username string `json:"username"`
Password string `json:"pass"`
}
CredentialsRequest request containing credentials
type File ¶
type File struct {
gorm.Model
Name string `gorm:"not null"`
LocalName string `gorm:"not null"`
User *User `gorm:"association_autoupdate:false;association_autocreate:false"`
UserID uint `gorm:"column:uploader;index"`
FileSize int64
FileType string
IsPublic bool `gorm:"default:false"`
PublicFilename sql.NullString `gorm:"unique"`
Groups []Group `gorm:"many2many:files_groups;association_autoupdate:false"`
Tags []Tag `gorm:"many2many:files_tags;association_autoupdate:false"`
Namespace *Namespace `gorm:"association_autoupdate:false;association_autocreate:false;"`
NamespaceID uint `sql:"index" gorm:"not null"`
Encryption sql.NullInt32
Checksum string
}
File a file uploaded to the db
func GetPublicFile ¶
GetPublicFile returns a file which is public
func (File) GetAttributes ¶
func (file File) GetAttributes() FileAttributes
GetAttributes get file attributes
func (File) GetNamespace ¶
GetNamespace return namespace of file
func (*File) GetPublicNameWithExtension ¶ added in v1.1.0
GetPublicNameWithExtension return the public name ending with the real file extension
func (File) IsInGroupList ¶
IsInGroupList return true if file is in one of the specified groups
func (File) IsInTagList ¶
IsInTagList return true if file has one of the specified tags
func (*File) RemoveGroups ¶
RemoveGroups remove groups from file
func (*File) RemoveTags ¶
RemoveTags remove tags to file
func (*File) SetEncryption ¶
SetEncryption set encryption
func (*File) SetUniqueFilename ¶
SetUniqueFilename sets unique filename
func (*File) SetVilibility ¶
SetVilibility sets public/private
type FileAttributes ¶
type FileAttributes struct {
Tags []string `json:"tags,omitempty"`
Groups []string `json:"groups,omitempty"`
Namespace string `json:"ns"`
}
FileAttributes attributes for a file
type FileListRequest ¶
type FileListRequest struct {
FileID uint `json:"fid"`
Name string `json:"name"`
AllNamespaces bool `json:"allns"`
OptionalParams OptionalRequetsParameter `json:"opt"`
Attributes FileAttributes `json:"attributes"`
}
FileListRequest contains file info (and a file)
type FileRequest ¶
type FileRequest struct {
FileID uint `json:"fid"`
Name string `json:"name,omitempty"`
PublicName string `json:"pubname,omitempty"`
Updates FileUpdateItem `json:"updates,omitempty"`
All bool `json:"all"`
Attributes FileAttributes `json:"attributes"`
}
FileRequest contains data to update a file
type FileResponseItem ¶
type FileResponseItem struct {
ID uint `json:"id"`
Size int64 `json:"size"`
CreationDate time.Time `json:"creation"`
Name string `json:"name"`
PublicName string `json:"pubname"`
IsPublic bool `json:"isPub"`
Attributes FileAttributes `json:"attrib"`
Encryption string `json:"e"`
Checksum string `json:"checksum"`
}
FileResponseItem file item for file response
type FileUpdateItem ¶
type FileUpdateItem struct {
IsPublic string `json:"ispublic,omitempty"`
NewName string `json:"name,omitempty"`
NewNamespace string `json:"namespace,omitempty"`
RemoveTags []string `json:"rem_tags,omitempty"`
RemoveGroups []string `json:"rem_groups,omitempty"`
AddTags []string `json:"add_tags,omitempty"`
AddGroups []string `json:"add_groups,omitempty"`
}
FileUpdateItem lists changes to a file
type Group ¶
type Group struct {
gorm.Model
Name string `gorm:"not null"`
NamespaceID uint `sql:"index" gorm:"not null"`
Namespace *Namespace `gorm:"association_autoupdate:false;association_autocreate:false"`
UserID uint `sql:"index" gorm:"not null"`
User *User `gorm:"association_autoupdate:false;association_autocreate:false"`
}
Group a group in DB
func FindGroups ¶
FindGroups find group in db
func GroupsFromStringArr ¶
GroupsFromStringArr return tag array from string array
func (Group) GetNamespace ¶
GetNamespace return namespace of group
type IDsResponse ¶ added in v1.1.0
type IDsResponse struct {
IDs []uint `json:"ids"`
}
IDsResponse response containing a list of ids
type ListFileResponse ¶
type ListFileResponse struct {
Files []FileResponseItem `json:"files"`
}
ListFileResponse response for list files
type LoginResponse ¶
LoginResponse response for login
type LoginSession ¶
type LoginSession struct {
gorm.Model
User *User `gorm:"association_autoupdate:false;association_autocreate:false"`
UserID uint
Token string
Requests int64
MachineID string
}
LoginSession session for loggedin user
func NewSession ¶
func NewSession(user *User, machineID string) *LoginSession
NewSession create new login session
type Namespace ¶
type Namespace struct {
gorm.Model
Name string `gorm:"not null"`
UserID uint `gorm:"column:creator;index"`
User *User `gorm:"association_autoupdate:false;association_autocreate:false"`
}
Namespace a namespace for files
func FindNamespace ¶
FindNamespace find namespace in DB
func FindUserNamespaces ¶
FindUserNamespaces get all namespaces for user
func GetNamespaceFromString ¶
GetNamespaceFromString return namespace from string
type NamespaceRequest ¶
type NamespaceRequest struct {
Namespace string `json:"ns"`
NewName string `json:"newName,omitempty"`
}
NamespaceRequest namespace action request
type Namespaceinfo ¶ added in v1.1.0
Namespaceinfo info for namespace
type OptionalRequetsParameter ¶
type OptionalRequetsParameter struct {
Verbose uint8 `json:"verb"`
}
OptionalRequetsParameter optional request parameter
type Permission ¶
type Permission uint8
Permission permission for roles
const ( NoPermission Permission = iota ReadPermission Writepermission )
Permissions
type PreviewTemplate ¶
type PreviewTemplate struct {
Filename string
PublicFilename string
PreviewType PreviewType
Host string
FileSizeStr string
Encrypted bool
MimeType string
}
PreviewTemplate template struct for preview
type PreviewType ¶
type PreviewType uint8
PreviewType type of preview
const ( DefaultPreviewType PreviewType = iota ImagePreviewType VideoPreviewType TextPreviewType )
Preview types
func PreviewTypeFromMime ¶
func PreviewTypeFromMime(sMime string) PreviewType
PreviewTypeFromMime get Type to preview from mime
type PublishResponse ¶
type PublishResponse struct {
PublicFilename string `json:"pubName"`
}
PublishResponse response for publishing a file
type ResponseStatus ¶
type ResponseStatus uint8
ResponseStatus the status of response
const ( //ResponseError if there was an error ResponseError ResponseStatus = 0 //ResponseSuccess if the response is successful ResponseSuccess ResponseStatus = 1 )
type Role ¶
type Role struct {
ID uint `gorm:"pk"`
RoleName string `gorm:"not null"`
IsAdmin bool `gorm:"default:false"`
AccesForeignNamespaces Permission `gorm:"type:smallint"`
MaxURLcontentSize int64
MaxUploadFileSize int64
CreateNamespaces bool
}
Role roles for user
type StringResponse ¶
type StringResponse struct {
String string `json:"content"`
}
StringResponse response containing only one string
type StringSliceResponse ¶
type StringSliceResponse struct {
Slice []string `json:"slice"`
}
StringSliceResponse response containing only one string slice
type Tag ¶
type Tag struct {
gorm.Model
Name string `gorm:"not null"`
NamespaceID uint `sql:"index" gorm:"not null"`
Namespace *Namespace `gorm:"association_autoupdate:false;association_autocreate:false"`
UserID uint `sql:"index" gorm:"not null"`
User *User `gorm:"association_autoupdate:false;association_autocreate:false"`
}
Tag a filetag
func TagsFromStringArr ¶
TagsFromStringArr return tag array from string array
func (Tag) GetNamespace ¶
GetNamespace return namespace of tag
type UpdateAttributeRequest ¶
type UpdateAttributeRequest struct {
Name string `json:"name"`
NewName string `json:"newname"`
Namespace string `json:"namespace"`
}
UpdateAttributeRequest contains data to update a tag
type UploadRequest ¶
type UploadRequest struct {
UploadType UploadType `json:"type"`
URL string `json:"url,omitempty"`
Name string `json:"name"`
Public bool `json:"pb,omitempty"`
PublicName string `json:"pbname,omitempty"`
Attributes FileAttributes `json:"attr,omitempty"`
Encryption string `json:"e,omitempty"`
ReplaceFile uint `json:"r,omitempty"`
Size int64 `json:"s"`
}
UploadRequest contains file info (and a file)
type UploadResponse ¶
type UploadResponse struct {
FileID uint `json:"fileID"`
Filename string `json:"filename"`
PublicFilename string `json:"publicFilename,omitempty"`
Checksum string `json:"checksum"`
FileSize int64 `json:"size"`
Namespace string `json:"ns"`
}
UploadResponse response for uploading file
type UploadType ¶
type UploadType uint8
UploadType type of upload
const ( FileUploadType UploadType = iota URLUploadType )
Available upload types
type User ¶
type User struct {
gorm.Model
Username string
Password string
RoleID uint `sql:"index"`
Role *Role `gorm:"association_autoupdate:false;association_autocreate:false"`
}
User user in db
func GetUserFromSession ¶
GetUserFromSession return user from session
func (User) AllowedToUploadURLs ¶
AllowedToUploadURLs gets upload limit
func (User) CanCreateNamespaces ¶ added in v1.1.0
CanCreateNamespaces return true if user can create user namespaces
func (User) CanReadForeignNamespace ¶
CanReadForeignNamespace return true if user is allowed to read in foreign namespaces
func (User) CanUploadFiles ¶
CanUploadFiles return true if user can upload files
func (User) CanWriteForeignNamespace ¶
CanWriteForeignNamespace return true if user is allowed to write in foreign namespaces
func (*User) CreateDefaultNamespace ¶
CreateDefaultNamespace creates user namespace
func (*User) GetAllGroups ¶ added in v1.1.0
GetAllGroups gets all groups for an user
func (*User) GetDefaultNamespaceName ¶
GetDefaultNamespaceName return the name of the default namespace for a user
func (*User) GetNamespaceName ¶ added in v1.1.0
GetNamespaceName gets the namespace for an user
func (*User) GetUsername ¶ added in v1.1.0
GetUsername Gets username of user
func (User) HasUploadLimit ¶
HasUploadLimit gets upload limit
type UserAttributeDataResponse ¶ added in v1.1.0
type UserAttributeDataResponse struct {
Namespace []Namespaceinfo `json:"nsData"`
}
UserAttributeDataResponse response for userattribute data
type UserAttributesRequest ¶ added in v1.1.0
type UserAttributesRequest struct {
Mode uint `json:"m"`
}
UserAttributesRequest request for getting namespaces and groups