libdatamanager

package module
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 26 Imported by: 6

README

libDataManager

A go package implementing the DataManager protocol

Documentation

Index

Constants

View Source
const (
	// KeystoreDBFile the sqlite DB containing the file-key associations
	KeystoreDBFile = ".keys.db"

	// KeyringService the servicename for the keyring
	KeyringService = "DataManagerCLI-keystore"
)
View Source
const (
	// Ping
	EPPing Endpoint = "/ping"

	// User
	EPUser     Endpoint = "/user"
	EPLogin    Endpoint = EPUser + "/login"
	EPRegister Endpoint = EPUser + "/register"

	// Files
	EPFile Endpoint = "/file"

	EPFileList    Endpoint = EPFile + "s"
	EPFileUpdate  Endpoint = EPFile + "/update"
	EPFileDelete  Endpoint = EPFile + "/delete"
	EPFileGet     Endpoint = EPFile + "/get"
	EPFilePublish Endpoint = EPFile + "/publish"

	// Upload
	EPFileUpload Endpoint = "/upload" + EPFile

	// Attribute
	EPAttribute  Endpoint = "/attribute"
	EPAttributes Endpoint = "/attributes"
	// Tags
	EPAttributeTag = EPAttribute + "/tag"
	EPTagCreate    = EPAttributeTag + "/create"
	EPTagUpdate    = EPAttributeTag + "/update"
	EPTagDelete    = EPAttributeTag + "/delete"
	EPTags         = EPAttributeTag + "/get"
	// Group
	EPAttributeGroup = EPAttribute + "/group"
	EPGroupCreate    = EPAttributeGroup + "/create"
	EPGroupUpdate    = EPAttributeGroup + "/update"
	EPGroupDelete    = EPAttributeGroup + "/delete"
	EPGroups         = EPAttributeGroup + "/get"

	// Namespace
	EPNamespace       Endpoint = "/namespace"
	EPNamespaceCreate          = EPNamespace + "/create"
	EPNamespaceUpdate          = EPNamespace + "/update"
	EPNamespaceDelete          = EPNamespace + "/delete"
	EPNamespaceList            = EPNamespace + "s"
)

Remote endpoints

View Source
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"

	// HeaderRequest request content
	HeaderRequest string = "Request"

	// HeaderEncryption encryption header
	HeaderEncryption string = "X-Encryption"

	// HeaderContentLength request content length
	HeaderContentLength string = "ContentLength"

	// HeaderFileID fileid header
	HeaderFileID string = "X-FileID"

	// HeaderChecksum files checksum
	HeaderChecksum string = "Checksum"
)
View Source
const (
	Boundary = "MachliJalKiRaniHaiJeevanUskaPaaniHai"
)

Boundary boundary for the part

View Source
const (
	// DefaultBuffersize The default buffersize for filestreams
	DefaultBuffersize = 10 * 1024
)

Variables

View Source
var (
	// ErrInvalidResponseHeaders error on missing or malformed response headers
	ErrInvalidResponseHeaders = errors.New("Invalid response headers")
	// ErrResponseError response returned an error
	ErrResponseError = errors.New("response returned an error")
	// ErrResponseFilenameInvalid if server returns no filename
	ErrResponseFilenameInvalid = errors.New("invalid filename received")
)
View Source
var (
	// ErrChecksumNotMatch error if the checksum of the downloaded
	// file doesn't match with the checksum of the remote file
	ErrChecksumNotMatch = errors.New("generated checksum not match")

	// ErrCipherNotSupported if cipher is not supported
	ErrCipherNotSupported = errors.New("cipher not supported")

	// ErrFileEncrypted error if no key was given and nodecrypt is false
	ErrFileEncrypted = errors.New("file is encrypted but no key was given")
)
View Source
var (
	// ErrKeyUnavailable if keystore key is unavailable
	ErrKeyUnavailable = errors.New("keyring key is unavailable")

	// ErrKeystoreNoDir error if keystore is no directory
	ErrKeystoreNoDir = errors.New("Keystore is not a directory")

	// ErrKeyAlreadyexists error if keystore already contains an entry for the given fileid
	ErrKeyAlreadyexists = errors.New("Keystore already contains given key")
)

Errors

View Source
var EncryptionCiphers = []string{
	"aes",
}

EncryptionCiphers supported encryption chipers

View Source
var (
	// ErrCancelled if something was cancelled
	ErrCancelled = errors.New("cancelled")
)
View Source
var (
	// ErrUnsupportedScheme error if url has an unsupported scheme
	ErrUnsupportedScheme = errors.New("Unsupported scheme")
)

Functions

func ChiperToInt

func ChiperToInt(c string) int32

ChiperToInt cipter to int

func ChiperToString

func ChiperToString(i int32) string

ChiperToString cipter to int

func DecryptAES added in v1.1.14

func DecryptAES(in io.Reader, out, hashwriter io.Writer, keyAes, buff []byte, cancelChan chan bool) (err error)

DecryptAES decrypt stuff

func EncryptAES added in v1.1.14

func EncryptAES(in io.Reader, out io.Writer, keyAes, buff []byte, cancel chan bool) (err error)

EncryptAES encrypts input stream and writes it to out

func EncryptionIValid

func EncryptionIValid(i int32) bool

EncryptionIValid return true if encryption i is valid

func GetFilesizeFromDownloadRequest added in v1.1.10

func GetFilesizeFromDownloadRequest(resp *http.Response) int64

GetFilesizeFromDownloadRequest returns the filesize from a file from the response headers

func IsValidCipher

func IsValidCipher(c string) bool

IsValidCipher return true if given cipher is valid

Types

type Attribute

type Attribute string

Attribute attribute for file (tag/group)

const (
	TagAttribute   Attribute = "tag"
	GroupAttribute Attribute = "group"
)

Attributes

type Authorization

type Authorization struct {
	Type    AuthorizationType
	Palyoad string
}

Authorization the authorization params for a server request

type AuthorizationType

type AuthorizationType string

AuthorizationType authorization type

const (
	Bearer AuthorizationType = "Bearer"
	Basic  AuthorizationType = "Basic"
)

Authorizanion types

type BulkPublishResponse

type BulkPublishResponse struct {
	Files []UploadResponse `json:"files"`
}

BulkPublishResponse response for publishing a file

type ContentType

type ContentType string

ContentType contenttype header of request

const (
	JSONContentType ContentType = "application/json"
)

Content types

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 Endpoint

type Endpoint string

Endpoint a remote url-path

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 FileChanges

type FileChanges struct {
	NewName                  string
	NewNamespace             string
	AddTags, AddGroups       []string
	RemoveTags, RemoveGroups []string
	SetPublic, SetPrivate    bool
}

FileChanges file changes for updating a file

type FileDownloadRequest added in v1.1.14

type FileDownloadRequest struct {
	LibDM
	ID         uint
	Name       string
	Namespace  string
	Decrypt    bool
	Key        []byte
	Buffersize int

	CancelDownload chan bool
	WriterProxy    WriterProxy
	ReaderProxy    ReaderProxy
	// contains filtered or unexported fields
}

FileDownloadRequest request for downloading a file

func (*FileDownloadRequest) DecryptWith added in v1.1.14

func (fileRequest *FileDownloadRequest) DecryptWith(key []byte) *FileDownloadRequest

DecryptWith sets key to decrypt file with. If key is nil, no decryption will be performed

func (*FileDownloadRequest) Do added in v1.1.14

func (fileRequest *FileDownloadRequest) Do() (*FileDownloadResponse, error)

Do requests a filedownload and returns the response The response body must be closed

func (*FileDownloadRequest) DownloadToFile added in v1.1.14

func (fileRequest *FileDownloadRequest) DownloadToFile(localFilePath string, fmode os.FileMode, appendFilename ...bool) (*FileDownloadResponse, error)

DownloadToFile downloads and saves a file to the given localFilePath. If the file exists, it will be overwritten

func (*FileDownloadRequest) GetBuffersize added in v1.1.14

func (fileRequest *FileDownloadRequest) GetBuffersize() int

GetBuffersize gets the buffersize

func (*FileDownloadRequest) GetReaderProxy added in v1.3.0

func (fileRequest *FileDownloadRequest) GetReaderProxy() ReaderProxy

GetReaderProxy of request

func (*FileDownloadRequest) GetWriterProxy added in v1.3.0

func (fileRequest *FileDownloadRequest) GetWriterProxy() WriterProxy

GetWriterProxy returns proxywriter of request

func (*FileDownloadRequest) IgnoreChecksum added in v1.1.14

func (fileRequest *FileDownloadRequest) IgnoreChecksum() *FileDownloadRequest

IgnoreChecksum ignores the checksum

func (*FileDownloadRequest) NoDecrypt added in v1.1.14

func (fileRequest *FileDownloadRequest) NoDecrypt() *FileDownloadRequest

NoDecrypt don't decrypt file while downloading

type FileDownloadResponse added in v1.1.14

type FileDownloadResponse struct {
	Response        *http.Response
	ServerFileName  string
	LocalChecksum   string
	ServerChecksum  string
	Size            int64
	Encryption      string
	FileID          uint
	DownloadRequest *FileDownloadRequest
}

FileDownloadResponse response for downloading a file

func (*FileDownloadResponse) SaveTo added in v1.1.14

func (fileresponse *FileDownloadResponse) SaveTo(w io.Writer, cancelChan chan bool) error

SaveTo download a file and write it to the writer while

func (*FileDownloadResponse) VerifyChecksum added in v1.1.14

func (fileresponse *FileDownloadResponse) VerifyChecksum() bool

VerifyChecksum Return if checksums are equal and not empty

func (*FileDownloadResponse) WriteToFile added in v1.1.14

func (fileresponse *FileDownloadResponse) WriteToFile(localFilePath string, fmode os.FileMode, cancelChan chan bool) error

WriteToFile saves a file to the given localFilePath containing the body of the given response

type FileListRequest

type FileListRequest struct {
	FileID         uint                     `json:"fid"`
	Name           string                   `json:"name"`
	AllNamespaces  bool                     `json:"allns"`
	OptionalParams OptionalRequetsParameter `json:"opt"`
	Order          string                   `json:"order,omitempty"`
	Attributes     FileAttributes           `json:"attributes"`
}

FileListRequest contains file info (and a file)

type FileListResponse

type FileListResponse struct {
	Files []FileResponseItem
}

FileListResponse response for listing files

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"`
	IsPublic     bool           `json:"isPub"`
	PublicName   string         `json:"pubname"`
	Attributes   FileAttributes `json:"attrib"`
	Encryption   string         `json:"e"`
	Checksum     string         `json:"checksum"`
}

FileResponseItem file item for file response

type FileSizeCallback added in v1.1.14

type FileSizeCallback func(int64)

FileSizeCallback gets called if the filesize is known

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 IDsResponse added in v1.1.2

type IDsResponse struct {
	IDs []uint `json:"ids"`
}

IDsResponse response containing a list of ids

type Keystore added in v1.1.1

type Keystore struct {
	Path string
	DB   *gorm.DB
	// contains filtered or unexported fields
}

Keystore a place to store keys

func NewKeystore added in v1.1.1

func NewKeystore(path string) *Keystore

NewKeystore create a new keystore

func (*Keystore) AddKey added in v1.1.1

func (store *Keystore) AddKey(fileID uint, keyPath string) error

AddKey Inserts key into keystore

func (*Keystore) Close added in v1.1.1

func (store *Keystore) Close() error

Close closes the keystore

func (*Keystore) DeleteKey added in v1.1.1

func (store *Keystore) DeleteKey(fileID uint) (*KeystoreFile, error)

DeleteKey Inserts key into keystore

func (*Keystore) GetFileInfo added in v1.1.7

func (store *Keystore) GetFileInfo() *os.FileInfo

GetFileInfo returns fileinfo for the keystore

func (*Keystore) GetFiles added in v1.1.7

func (store *Keystore) GetFiles() ([]KeystoreFile, error)

GetFiles returns a slice containing all keystore Files

func (*Keystore) GetKey added in v1.1.1

func (store *Keystore) GetKey(fileID uint) ([]byte, error)

GetKey returns the key assigned to the fileID. If FileID or key was not found, error is not nil

func (*Keystore) GetKeyCount added in v1.1.13

func (store *Keystore) GetKeyCount(validKeysOnly ...bool) (int, error)

GetKeyCount reutrns count of keys

func (*Keystore) GetKeyFile added in v1.1.1

func (store *Keystore) GetKeyFile(fileID uint) (*KeystoreFile, error)

GetKeyFile returns a keyfile with assigned to the fileID

func (*Keystore) GetKeystoreDataFile added in v1.1.1

func (store *Keystore) GetKeystoreDataFile() string

GetKeystoreDataFile returns the keystore db filepath

func (*Keystore) GetKeystoreFile added in v1.1.1

func (store *Keystore) GetKeystoreFile(file string) string

GetKeystoreFile returns the full path of file

func (*Keystore) HasKey added in v1.1.13

func (store *Keystore) HasKey(fileID uint) (bool, error)

HasKey check if keystore already contains given fileID

func (*Keystore) Open added in v1.1.1

func (store *Keystore) Open() error

Open opens the keystore

type KeystoreFile added in v1.1.1

type KeystoreFile struct {
	gorm.Model
	FileID uint
	Key    string
}

KeystoreFile the keystore row

type LibDM

type LibDM struct {
	Config                *RequestConfig
	MaxConnectionsPerHost int
}

LibDM data required in all requests

func NewLibDM

func NewLibDM(config *RequestConfig) *LibDM

NewLibDM create new libDM "class"

func (LibDM) CreateAttribute added in v1.2.4

func (libdm LibDM) CreateAttribute(attribute Attribute, namespace, name string) (*RestRequestResponse, error)

CreateAttribute update an attribute

func (LibDM) CreateNamespace

func (libdm LibDM) CreateNamespace(name string) (*StringResponse, error)

CreateNamespace creates a namespace

func (LibDM) DeleteAttribute

func (libdm LibDM) DeleteAttribute(attribute Attribute, namespace, name string) (*RestRequestResponse, error)

DeleteAttribute update an attribute

func (LibDM) DeleteFile

func (libdm LibDM) DeleteFile(name string, id uint, all bool, attributes FileAttributes) (*IDsResponse, error)

DeleteFile deletes the desired file(s)

func (LibDM) DeleteNamespace

func (libdm LibDM) DeleteNamespace(name string) (*StringResponse, error)

DeleteNamespace update a namespace

func (LibDM) GetGroups added in v1.0.7

func (libdm LibDM) GetGroups(namespace string) ([]Attribute, error)

GetGroups returns an array of attributes containing groups available in given namespace

func (LibDM) GetNamespaces

func (libdm LibDM) GetNamespaces() (*StringSliceResponse, error)

GetNamespaces get all namespaces

func (LibDM) GetTags added in v1.0.7

func (libdm LibDM) GetTags(namespace string) ([]Attribute, error)

GetTags returns an array of attributes containing tags available in given namespace

func (LibDM) GetUserAttributeData added in v1.2.2

func (libdm LibDM) GetUserAttributeData() (*UserAttributeDataResponse, error)

GetUserAttributeData get attribute data for an user

func (LibDM) ListFiles

func (libdm LibDM) ListFiles(name string, id uint, allNamespaces bool, attributes FileAttributes, verbose uint8) (*FileListResponse, error)

ListFiles lists the files corresponding to the args

func (LibDM) Login

func (libdm LibDM) Login(username, password string) (*LoginResponse, error)

Login login into the server

func (LibDM) NewFileRequest added in v1.1.14

func (libdm LibDM) NewFileRequest(id uint, name, namespace string) *FileDownloadRequest

NewFileRequest create a new filerequest

func (LibDM) NewFileRequestByID added in v1.1.14

func (libdm LibDM) NewFileRequestByID(fileID uint) *FileDownloadRequest

NewFileRequestByID create a new filerequest by file id

func (LibDM) NewFileRequestByName added in v1.1.14

func (libdm LibDM) NewFileRequestByName(name, namespace string) *FileDownloadRequest

NewFileRequestByName create a new filerequest by name

func (*LibDM) NewRequest added in v1.1.13

func (limdm *LibDM) NewRequest(endpoint Endpoint, payload interface{}) *Request

NewRequest creates a new post request

func (LibDM) NewUploadRequest added in v1.1.12

func (libdm LibDM) NewUploadRequest(name string, attributes FileAttributes) *UploadRequest

NewUploadRequest create a new uploadrequest

func (LibDM) Ping added in v1.1.13

func (libdm LibDM) Ping() (*StringResponse, error)

Ping pings a server the REST way to ensure it is reachable

func (LibDM) PublishFile

func (libdm LibDM) PublishFile(name string, id uint, publicName string, all bool, attributes FileAttributes) (interface{}, error)

PublishFile publishs a file. If "all" is true, the response object is BulkPublishResponse. Else it is PublishResponse

func (LibDM) Register

func (libdm LibDM) Register(username, password string) (*RestRequestResponse, error)

Register create a new account. Return true on success

func (LibDM) Request

func (libdm LibDM) Request(ep Endpoint, payload, response interface{}, authorized bool) (*RestRequestResponse, error)

Request do a request using libdm

func (LibDM) UpdateAttribute

func (libdm LibDM) UpdateAttribute(attribute Attribute, namespace, name, newName string) (*RestRequestResponse, error)

UpdateAttribute update an attribute

func (LibDM) UpdateFile

func (libdm LibDM) UpdateFile(name string, id uint, namespace string, all bool, changes FileChanges) (*CountResponse, error)

UpdateFile updates a file on the server

func (LibDM) UpdateNamespace

func (libdm LibDM) UpdateNamespace(name, newName string) (*StringResponse, error)

UpdateNamespace update a namespace

func (*LibDM) WithMaxConnections added in v1.3.0

func (libdm *LibDM) WithMaxConnections(maxConnecetions int) *LibDM

WithMaxConnections per host

type LoginResponse

type LoginResponse struct {
	Token     string `json:"token"`
	Namespace string `json:"ns"`
}

LoginResponse response for login

type Method

type Method string

Method http request method

const (
	GET    Method = "GET"
	POST   Method = "POST"
	DELETE Method = "DELETE"
	PUT    Method = "PUT"
)

Requests

type NamespaceRequest

type NamespaceRequest struct {
	Namespace string `json:"ns"`
	NewName   string `json:"newName,omitempty"`
}

NamespaceRequest namespace action request

type Namespaceinfo added in v1.2.2

type Namespaceinfo struct {
	Name   string   `json:"ns"`
	Groups []string `json:"groups"`
}

Namespaceinfo info for namespace

type OptionalRequetsParameter

type OptionalRequetsParameter struct {
	Verbose uint8 `json:"verb"`
}

OptionalRequetsParameter optional request parameter

type PingRequest

type PingRequest struct {
	Payload string
}

PingRequest a ping request content

type PublishResponse

type PublishResponse struct {
	PublicFilename string `json:"pubName"`
}

PublishResponse response for publishing a file

type ReaderProxy added in v1.3.0

type ReaderProxy func(io.Reader) io.Reader

ReaderProxy proxy writing

var NoProxyReader ReaderProxy = func(r io.Reader) io.Reader {
	return r
}

NoProxyReader use to fill proxyWriter arg in UpdloadFile

type Request

type Request struct {
	RequestType           RequestType
	Endpoint              Endpoint
	Payload               interface{}
	Config                *RequestConfig
	Method                Method
	ContentType           ContentType
	Authorization         *Authorization
	Headers               map[string]string
	BenchChan             chan time.Time
	MaxConnectionsPerHost int
}

Request a rest server request

func (*Request) BuildClient

func (request *Request) BuildClient() *http.Client

BuildClient return client

func (Request) Do

func (request Request) Do(retVar interface{}) (*RestRequestResponse, error)

Do a better request method

func (*Request) DoHTTPRequest

func (request *Request) DoHTTPRequest() (*http.Response, error)

DoHTTPRequest do plain http request

func (*Request) WithAuth

func (request *Request) WithAuth(a Authorization) *Request

WithAuth with authorization

func (*Request) WithAuthFromConfig

func (request *Request) WithAuthFromConfig() *Request

WithAuthFromConfig with authorization

func (*Request) WithBenchCallback

func (request *Request) WithBenchCallback(c chan time.Time) *Request

WithBenchCallback with bench

func (*Request) WithConnectionLimit added in v1.3.0

func (request *Request) WithConnectionLimit(maxConnections int) *Request

WithConnectionLimit set limit of max connectionts per host

func (*Request) WithContentType

func (request *Request) WithContentType(ct ContentType) *Request

WithContentType with contenttype

func (*Request) WithHeader

func (request *Request) WithHeader(name string, value string) *Request

WithHeader add header to request

func (*Request) WithMethod

func (request *Request) WithMethod(m Method) *Request

WithMethod use a different method

func (*Request) WithRequestType

func (request *Request) WithRequestType(rType RequestType) *Request

WithRequestType use different request type

type RequestConfig

type RequestConfig struct {
	IgnoreCert   bool
	URL          string
	MachineID    string
	Username     string
	SessionToken string
}

RequestConfig configurations for requests

func (RequestConfig) GetBearerAuth

func (rc RequestConfig) GetBearerAuth() Authorization

GetBearerAuth returns bearer authorization from config

type RequestType

type RequestType uint8

RequestType type of request

const (
	JSONRequestType RequestType = iota
	RawRequestType
)

Request types

type ResponseErr

type ResponseErr struct {
	Response *RestRequestResponse
	Err      error
}

ResponseErr response error

func NewErrorFromResponse

func NewErrorFromResponse(r *RestRequestResponse, err ...error) *ResponseErr

NewErrorFromResponse return error from response

func (*ResponseErr) Error

func (reserr *ResponseErr) Error() string

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 RestRequestResponse

type RestRequestResponse struct {
	HTTPCode int
	Status   ResponseStatus
	Message  string
	Headers  *http.Header
}

RestRequestResponse the response of a rest call

type SortByName added in v1.2.3

type SortByName []Namespaceinfo

SortByName sorts NamespaceInfo by name

func (SortByName) Len added in v1.2.3

func (a SortByName) Len() int

func (SortByName) Less added in v1.2.3

func (a SortByName) Less(i, j int) bool

func (SortByName) Swap added in v1.2.3

func (a SortByName) Swap(i, j int)

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 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 {
	LibDM
	Name          string
	Publicname    string
	Public        bool
	Attribute     FileAttributes
	ReplaceFileID uint
	Encryption    string
	EncryptionKey []byte
	Buffersize    int

	ProxyWriter WriterProxy
	ProxyReader ReaderProxy
	Archive     bool
	Compressed  bool
	// contains filtered or unexported fields
}

UploadRequest a uploadrequest

func (*UploadRequest) BuildRequestStruct added in v1.1.12

func (uploadRequest *UploadRequest) BuildRequestStruct(Type UploadType) *UploadRequestStruct

BuildRequestStruct create a uploadRequset struct using Type

func (*UploadRequest) Compress added in v1.2.9

func (uploadRequest *UploadRequest) Compress() *UploadRequest

Compress the uploaded file

func (*UploadRequest) Do added in v1.1.12

func (uploadRequest *UploadRequest) Do(body io.Reader, payload interface{}, contentType ContentType) (*UploadResponse, error)

Do does the final upload http request and uploads the src

func (*UploadRequest) Encrypted added in v1.1.12

func (uploadRequest *UploadRequest) Encrypted(encryptionMethod string, key []byte) *UploadRequest

Encrypted Upload a file encrypted

func (*UploadRequest) GetBuffersize added in v1.1.14

func (uploadRequest *UploadRequest) GetBuffersize() int

GetBuffersize returns the buffersize

func (*UploadRequest) GetReaderProxy added in v1.3.0

func (uploadRequest *UploadRequest) GetReaderProxy() ReaderProxy

GetReaderProxy returns proxyReader for uploadRequest

func (*UploadRequest) GetWriterProxy added in v1.3.0

func (uploadRequest *UploadRequest) GetWriterProxy() WriterProxy

GetWriterProxy returns proxywriter for uploadRequest

func (*UploadRequest) MakePublic added in v1.1.12

func (uploadRequest *UploadRequest) MakePublic(publicName string) *UploadRequest

MakePublic upload and publish a file. If publciName is empty a random public name will be created serverside

func (*UploadRequest) ReplaceFile

func (uploadRequest *UploadRequest) ReplaceFile(fileID uint) *UploadRequest

ReplaceFile replace a file instead creating a new one

func (*UploadRequest) SetFileSizeCallback added in v1.1.14

func (uploadRequest *UploadRequest) SetFileSizeCallback(cb FileSizeCallback) *UploadRequest

SetFileSizeCallback sets the callback if the filesize is known

func (*UploadRequest) UploadArchivedFolder added in v1.2.9

func (uploadRequest *UploadRequest) UploadArchivedFolder(uri string, uploadDone chan string, cancel chan bool) (*UploadResponse, error)

UploadArchivedFolder uploads the given folder to the server

func (*UploadRequest) UploadBodyBuilder added in v1.1.17

func (uploadRequest *UploadRequest) UploadBodyBuilder(reader io.Reader, inpSize int64, doneChan chan string, cancel chan bool) (r *io.PipeReader, contentType string, size int64)

UploadBodyBuilder build the body for the upload file request

func (*UploadRequest) UploadFile added in v1.1.12

func (uploadRequest *UploadRequest) UploadFile(f *os.File, uploadDone chan string, cancel chan bool) (*UploadResponse, error)

UploadFile uploads the given file to the server

func (*UploadRequest) UploadFromReader added in v1.1.12

func (uploadRequest *UploadRequest) UploadFromReader(r io.Reader, size int64, uploadDone chan string, cancel chan bool) (*UploadResponse, error)

UploadFromReader upload a file using r as data source

func (UploadRequest) UploadURL added in v1.1.12

func (uploadRequest UploadRequest) UploadURL(u *url.URL) (*UploadResponse, error)

UploadURL uploads an url

type UploadRequestStruct added in v1.1.12

type UploadRequestStruct 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"`
	Compressed  bool           `json:"compr,omitempty"`
	Archived    bool           `json:"arved,omitempty"`
	Size        int64          `json:"s"`
}

UploadRequestStruct 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 UserAttributeDataResponse added in v1.2.2

type UserAttributeDataResponse struct {
	Namespace []Namespaceinfo `json:"nsData"`
}

UserAttributeDataResponse response for userattribute data

type UserAttributesRequest added in v1.2.4

type UserAttributesRequest struct {
	Mode uint `json:"m"`
}

UserAttributesRequest request for getting namespaces and groups

type WriterProxy added in v1.1.14

type WriterProxy func(io.Writer) io.Writer

WriterProxy proxy writing

var NoProxyWriter WriterProxy = func(w io.Writer) io.Writer {
	return w
}

NoProxyWriter use to fill proxyWriter arg in UpdloadFile

Directories

Path Synopsis
config module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL