Documentation ¶
Index ¶
- Constants
- Variables
- func GetCloudChannel(s *dg.Session) (*dg.Channel, error)
- func IsCloudChannel(s *dg.Session, channelID string) (bool, error)
- type ChunkInfo
- type Compression
- type CompressionLevel
- type CompressionType
- type DiscFile
- type DiscFolder
- type DiscStorage
- func (st DiscStorage) Delete(filename string) error
- func (st DiscStorage) DoesFileExist(filename string) (bool, error)
- func (st DiscStorage) GetFile(filename string) (*DiscFile, error)
- func (st DiscStorage) ListFiles(folder string) ([]FileInfo, error)
- func (st DiscStorage) Open(filename string) (fs.File, error)
- func (st DiscStorage) ReadDir(dir string) ([]fs.DirEntry, error)
- func (st DiscStorage) Receive(into io.Writer, filename string) error
- func (st DiscStorage) ReceiveAllAtOnce(into io.Writer, filename string) error
- func (st DiscStorage) ReceiveCompressed(into io.Writer, filename string) error
- func (st DiscStorage) Send(file io.Reader, info FileInfo, chunkSize int) error
- func (st DiscStorage) SendCompressed(file io.Reader, info FileInfo, chunkSize int) error
- func (st DiscStorage) SendFile(file *os.File, chunkSize int) error
- func (st DiscStorage) Stat(filename string) (fs.FileInfo, error)
- type FileChunk
- type FileInfo
- func (f FileInfo) FullPath() string
- func (f FileInfo) IsDir() bool
- func (fi FileInfo) MarshalJSON() ([]byte, error)
- func (f FileInfo) ModTime() time.Time
- func (f FileInfo) Mode() fs.FileMode
- func (f FileInfo) Name() string
- func (f FileInfo) Size() int64
- func (f FileInfo) Sys() interface{}
- func (fi *FileInfo) UnmarshalJSON(data []byte) error
- type PartInfo
Constants ¶
const ( B = 1 << (iota * 10) KB MB GB TB )
const Root = "/"
Variables ¶
var ErrFileNotFound = errors.New("file couldn't be found")
Functions ¶
func GetCloudChannel ¶
GetCloudChannel looks through all the channels the bot is in and returns the first one it thinks to be a valid cloud channel
Types ¶
type ChunkInfo ¶
type ChunkInfo struct { File FileInfo `json:"file"` Part PartInfo `json:"part"` Compression Compression `json:"compression"` Url string `json:"-"` }
type Compression ¶
type Compression struct { Level CompressionLevel `json:"level"` Type CompressionType `json:"type"` }
type CompressionLevel ¶
type CompressionLevel int16
const ( NoCompression CompressionLevel = flate.NoCompression BestSpeed CompressionLevel = flate.BestSpeed BestCompression CompressionLevel = flate.BestCompression DefaultCompression CompressionLevel = flate.DefaultCompression HuffmanOnly CompressionLevel = flate.HuffmanOnly )
func (CompressionLevel) MarshalJSON ¶
func (c CompressionLevel) MarshalJSON() ([]byte, error)
func (CompressionLevel) String ¶
func (c CompressionLevel) String() string
func (*CompressionLevel) UnmarshalJSON ¶
func (c *CompressionLevel) UnmarshalJSON(input []byte) error
type CompressionType ¶
type CompressionType int16
const ( EachChunk CompressionType = iota << 8 WholeFile )
func (CompressionType) MarshalJSON ¶
func (c CompressionType) MarshalJSON() ([]byte, error)
func (CompressionType) String ¶
func (c CompressionType) String() string
func (*CompressionType) UnmarshalJSON ¶
func (c *CompressionType) UnmarshalJSON(input []byte) error
type DiscFile ¶
type DiscFile struct {
// contains filtered or unexported fields
}
DiscFile is a lazy file descriptor. It downloads the file it points to only when Read() is called
func (DiscFile) ConcreteStat ¶
type DiscFolder ¶
type DiscFolder struct{ FileInfo }
func (DiscFolder) Type ¶
func (df DiscFolder) Type() fs.FileMode
type DiscStorage ¶
type DiscStorage struct {
// contains filtered or unexported fields
}
DiscStorage contains the necessary information to connect to the cloud channel
func NewStorage ¶
func NewStorage(s *dg.Session, channelId string) DiscStorage
NewStorage builds a new DiscStorage
func (DiscStorage) Delete ¶
func (st DiscStorage) Delete(filename string) error
func (DiscStorage) DoesFileExist ¶
func (st DiscStorage) DoesFileExist(filename string) (bool, error)
DoesFileExist checks if a file exists on the cloud channel
func (DiscStorage) GetFile ¶
func (st DiscStorage) GetFile(filename string) (*DiscFile, error)
Open returns a DiscFile if found on the channel
func (DiscStorage) ListFiles ¶
func (st DiscStorage) ListFiles(folder string) ([]FileInfo, error)
ListFiles lists all the files `st` can find
func (DiscStorage) Receive ¶
func (st DiscStorage) Receive(into io.Writer, filename string) error
ReceiveAllAtOnce looks for the file named `name` in the channel with the provided `channelID` with the provided session, storing the result into `into`. It writes each piece into `into` as soon as it comes todo: remove duplication between this and ReceiveAllAtOnce()?
func (DiscStorage) ReceiveAllAtOnce ¶
func (st DiscStorage) ReceiveAllAtOnce(into io.Writer, filename string) error
ReceiveAllAtOnce looks for the file named `name` in the channel with the provided `channelID` with the provided session, storing the result into `into`. It first downloads the whole file, then writes it all at once into `into`. If you'd rather get each piece as soon as it arrives try using Receive()
func (DiscStorage) ReceiveCompressed ¶
func (st DiscStorage) ReceiveCompressed(into io.Writer, filename string) error
func (DiscStorage) SendCompressed ¶
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
func (FileInfo) MarshalJSON ¶
field names `Name` and `Size` are necessary for fs.FileInfo, se we make them unexported