gokies

module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT

README

Gokies

A small private collection of functionality for projects using http, rest and azure as a storage.

StorageAbstraction

This is a collection of storage targets. All of them implement the IFileStorage interface. It allows to set a root directory to which all the paths are relative to.

Interface
type IFileStorage interface {
// CreateDirectory(dirName string) error

Write(fileName string, fileSize int64, reader io.ReadSeeker) error
Read(fileName string) (io.ReadCloser, error)
FileSize(fileName string) (int64, error)
DeleteDirectory(directory string) error
DeleteFile(fileName string) error
Walk(directory string, walk WalkFunc) error
Join(paths ...string) string
}
Example
localStorage := localstorage.NewLocalStorage("./dir")
azureStorage := azurestorage.NewAzureStorage("accountName", "accountKey", "containerName")

Compression

Compress and Extract files and folders using gzip and tar. The compression and extraction is using the storage abstraction.

storage := localstorage.NewLocalStorage("dir")
// Create a new Compression object
compExtractor := compression.NewCompression(storage)
file, err := os.OpenFile("compress.tar.gz", os.O_CREATE|os.O_WRONLY, 0777)
if err != nil {
t.Errorf("Unable to open file: %v", err)
return
}

// compress ./dir/compressDir into compress.tar.gz
err = compressor.CompressDir("compressDir", file

FileContainer (IFileManager & FileManager)

Currently still a mess, trying to organize it better. Simple task is to have a directory from where files can be served. With backup and upload functionality:

  • ability to upload files to a folder inside this directory using a tar.gz.
  • download backup files of a folder inside this directory using a tar.gz.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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