storage

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 5 Imported by: 0

README

本地文件存储 Storage

storage 包是基于项目的文件存储管理工具。默认有公开文件管理工具 storage.Public(),和内部文件管理工具 storage.Disk(string), 以及系统临时文件管理工具 storage.Temp()

公开文件和内部文件的存储,均相对于项目的根目录(运行时目录)。而,临时文件则存储于系统的临时目录,受操作系统影响。

基础接口 IStorage

	Dir() string      // 获得文件存储的目录
	Path() string     // 获得文件存储的路径
	Filename() string // 获得文件名

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPrivateStorage

type IPrivateStorage interface {
	IStorage

	AppendDir(dirs ...string) IPrivateStorage // 追加存储目录
	SetName(name string) IPrivateStorage      // 设置文件名
}

func Disk

func Disk(dir string) IPrivateStorage

func Temp

func Temp() IPrivateStorage

type IPublicStorage

type IPublicStorage interface {
	IStorage

	AppendDir(dirs ...string) IPublicStorage // 追加存储目录
	SetName(name string) IPublicStorage      // 设置文件名

	URL() string                    // 获得文件的访问链接(不含 host)
	URLWithHost(host string) string // 获得文件的访问链接(含 host)
}

func Public

func Public() IPublicStorage

func PublicFromFile

func PublicFromFile(filename string) IPublicStorage

func PublicFromUrl

func PublicFromUrl(fileURL string) IPublicStorage

type IStorage

type IStorage interface {
	Dir() string      // 获得文件存储的目录
	Path() string     // 获得文件存储的路径
	Filename() string // 获得文件名
}

Jump to

Keyboard shortcuts

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