filestore

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 0 Imported by: 0

README

Filestore GoDoc

Import
import "github.com/4vn/filestore/mongodb"
Usage
fs, _ := mongodb.NewFileStore("mongodb://localhost:27017", "testdb", "myfs.")
defer fs.Close()

data := []byte(`hello world!`)

fileId, err := fs.Put(data, bson.M{"filename": "hello.txt"})
if err != nil {
	log.Fatalf("Error uploading file: %v", err)
}
log.Printf("File uploaded with ID: %s\n", fileId)

downloadedData, downloadedMetadata, err := fs.Get(fileId)
if err != nil {
	log.Fatalf("Error downloading file: %v", err)
}

log.Printf("Downloaded data: %s\n", downloadedData)
log.Printf("Downloaded metadata: %v\n", downloadedMetadata)

if err := fs.Delete(fileId); err != nil {
	panic(err)
}
License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IFileStore

type IFileStore interface {
	Put(data []byte, metadata map[string]interface{}) (fileId string, err error)
	Get(fileId string) (data []byte, metadata map[string]interface{}, err error)
	Delete(fileId string) error
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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