storage

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 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 追加存储目录
	AppendDir(dirs ...string) IPrivateStorage
	// SetName 设置文件名
	SetName(name string) IPrivateStorage
}

func Disk

func Disk(dir string) IPrivateStorage

func Temp

func Temp() IPrivateStorage

type IPublicStorage

type IPublicStorage interface {
	IStorage

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

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

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 获得文件存储的目录
	Dir() string
	// Path 获得文件存储的路径
	Path() string
	// Filename 获得文件名
	Filename() string
}

Jump to

Keyboard shortcuts

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