file

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

This package simplifies file IO and handles the file path when using JSON or MSGPACK. When using Output the path will be the URI like /api/my/file/uri/{unique_id} When using Input the path will be the relative file system path my/relative/file/path/{unique_id}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFileInfo

func IsFileInfo(maybeFile map[string]interface{}) bool

func NameWithExt

func NameWithExt(fileName string, ext string) string

Types

type IO

type IO struct {
	Hash string
	// contains filtered or unexported fields
}

func FromMap

func FromMap(baseFilePath string, m map[string]interface{}) *IO

func New

func New(baseDir string, meta Meta) *IO

func (*IO) ContentType

func (me *IO) ContentType() string

func (*IO) MarshalBSON

func (me *IO) MarshalBSON() ([]byte, error)

func (*IO) MarshalJSON

func (me *IO) MarshalJSON() ([]byte, error)

func (*IO) MarshalMsgpack

func (me *IO) MarshalMsgpack() ([]byte, error)

func (*IO) Meta

func (me *IO) Meta() Meta

func (*IO) Name

func (me *IO) Name() string

func (*IO) NameWithExt

func (me *IO) NameWithExt(ext string) string

func (*IO) Path

func (me *IO) Path() string

func (*IO) PathName

func (me *IO) PathName() string

func (*IO) SetBaseDir

func (me *IO) SetBaseDir(baseDir string)

func (*IO) SetRef

func (me *IO) SetRef(ref string)

func (*IO) SetSize

func (me *IO) SetSize(s int64)

func (*IO) Size

func (me *IO) Size() int64

func (*IO) String

func (me *IO) String() string

func (*IO) ToMap

func (me *IO) ToMap() map[string]interface{}

func (*IO) UnmarshalBSON

func (me *IO) UnmarshalBSON(raw []byte) error

func (*IO) UnmarshalJSON

func (me *IO) UnmarshalJSON(b []byte) error

func (*IO) UnmarshalMsgpack

func (me *IO) UnmarshalMsgpack(b []byte) error

func (*IO) Update

func (me *IO) Update(name, contentType string)

type InMemoryFileInfo

type InMemoryFileInfo struct {
	Path string
	Len  int
}

func (InMemoryFileInfo) IsDir

func (fi InMemoryFileInfo) IsDir() bool

func (InMemoryFileInfo) ModTime

func (fi InMemoryFileInfo) ModTime() time.Time

func (InMemoryFileInfo) Mode

func (fi InMemoryFileInfo) Mode() os.FileMode

func (InMemoryFileInfo) Name

func (fi InMemoryFileInfo) Name() string

func (InMemoryFileInfo) Size

func (fi InMemoryFileInfo) Size() int64

func (InMemoryFileInfo) Sys

func (fi InMemoryFileInfo) Sys() interface{}

type MapIO

type MapIO map[string]interface{}

func (MapIO) Get

func (me MapIO) Get(path string) interface{}

Get retrieves the value by a path like key.key2.key3

func (MapIO) GetAllDataAndFiles

func (me MapIO) GetAllDataAndFiles(baseDir string) (dat map[string]interface{}, files []string)

func (MapIO) GetAllFileInfos

func (me MapIO) GetAllFileInfos(baseDir string) []*IO

func (MapIO) GetFileInfo

func (me MapIO) GetFileInfo(baseDir, path string) *IO

GetFileInfo retrieves the value by a path like key.key2.key3

func (MapIO) MakeFileInfos

func (me MapIO) MakeFileInfos(baseDir string)

MakeFileInfos makes sure all file map patterns are replaced by actual Info's

func (MapIO) MergeWith

func (me MapIO) MergeWith(v map[string]interface{})

type Meta

type Meta struct {
	Name        string
	ContentType string
	Size        int64
	Hash        string
}

Jump to

Keyboard shortcuts

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