sqlitefs

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 10 Imported by: 0

README

sqlitefs

sqlitefs - пакет для подключения sqlite3 таблицы в качестве файловой системы.

Использование

go get github.com/jilio/sqlitefs

db, err := sql.Open("sqlite", "sample.db")
if err != nil {
    panic(err)
}
defer db.Close()

sfs, err := sqlitefs.NewSQLiteFS(db)
if err != nil {
    panic(err)
}

r := gin.Default()
r.GET("/logo.png", func(c *gin.Context) {
    c.FileFromFS("/images/sqlitefs.png", sfs)
})
r.Run() 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLiteFS

type SQLiteFS struct {
	// contains filtered or unexported fields
}

SQLiteFS реализует интерфейс http.FileSystem для файлов, хранящихся в SQLite.

func NewSQLiteFS

func NewSQLiteFS(db *sql.DB) (*SQLiteFS, error)

NewSQLiteFS создает новый экземпляр SQLiteFS с заданной базой данных. Проверяет наличие необходимых таблиц и создает их при отсутствии.

func (*SQLiteFS) Open

func (fs *SQLiteFS) Open(name string) (http.File, error)

Open открывает файл по указанному пути.

type SQLiteFile

type SQLiteFile struct {
	// contains filtered or unexported fields
}

SQLiteFile реализует интерфейс http.File.

func NewSQLiteFile

func NewSQLiteFile(db *sql.DB, path string) (*SQLiteFile, error)

NewSQLiteFile создает новый экземпляр SQLiteFile для заданного пути.

func (*SQLiteFile) Close

func (f *SQLiteFile) Close() error

func (*SQLiteFile) Read

func (f *SQLiteFile) Read(p []byte) (int, error)

func (*SQLiteFile) Readdir

func (f *SQLiteFile) Readdir(count int) ([]os.FileInfo, error)

func (*SQLiteFile) Seek

func (f *SQLiteFile) Seek(offset int64, whence int) (int64, error)

func (*SQLiteFile) Stat

func (f *SQLiteFile) Stat() (os.FileInfo, error)

type SQLiteWriter

type SQLiteWriter struct {
	// contains filtered or unexported fields
}

func NewSQLiteWriter

func NewSQLiteWriter(db *sql.DB, path string) *SQLiteWriter

func (*SQLiteWriter) Close

func (w *SQLiteWriter) Close() error

func (*SQLiteWriter) Write

func (w *SQLiteWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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