bucket

package
v0.0.0-...-a1b0cfd Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddObject

func AddObject(db *sql.DB, bucketID, objectID, filename string) error

AddObject adds an object to the database if it doesn't already exist

func AddVersion

func AddVersion(db *sql.DB, bucketID, objectID, versionID, rootVersion string, metadata VersionMetadata, data []byte) error

func CreateBucket

func CreateBucket(db *sql.DB, bucketID string, owner string) error

CreateBucket inserts a new bucket into the database

func DeleteBucket

func DeleteBucket(db *sql.DB, bucketID string) error

Deletes all the contents of a bucket

func DeleteObject

func DeleteObject(db *sql.DB, bucketID, objectID string) error

Remove object from database

func DeleteObjectByVersion

func DeleteObjectByVersion(db *sql.DB, bucketID, objectID, versionID string) error

func GenerateObjectID

func GenerateObjectID() string

func GetEncryptionKey

func GetEncryptionKey(cfg *config.Config) ([]byte, error)

GetEncryptionKey retrieves the encryption key from the configuration

func GetLatestVersion

func GetLatestVersion(db *sql.DB, objectID string) string

Pls review this, I believe we can still optimize it better

func GetObjectMetadataAllVersions

func GetObjectMetadataAllVersions(db *sql.DB, objectID string) (map[string]VersionMetadata, error)

func GetObjectsInBucket

func GetObjectsInBucket(db *sql.DB, bucketID string) ([]string, error)

Returns all the objects in a bucket

func GetRootVersion

func GetRootVersion(db *sql.DB, objectID string) (string, error)

func InitDB

func InitDB() (*sql.DB, error)

InitDB initializes the SQLite database InitDB initializes the database if it doesn't exist and returns a connection to it.

func ListAllBuckets

func ListAllBuckets(db *sql.DB, owner string) ([]string, error)

func ListObjectVersions

func ListObjectVersions(db *sql.DB, objectID string) ([]string, error)

ListObjectVersions lists all versions of an object

func ReadMetadataJson

func ReadMetadataJson(db *sql.DB, bucketID, objectID, versionID string, filename string) error

func SetBucketPermissions

func SetBucketPermissions(db *sql.DB, bucketID string, read, write []string) error

SetBucketPermissions sets read/write permissions for a bucket

func UpdateFileVersionIfItExists

func UpdateFileVersionIfItExists(db *sql.DB, originalFile, bucketID, objectID string) (string, string, error)

Types

type Bucket

type Bucket struct {
	ID    string
	Owner string
}

Bucket represents a storage bucket

func GetBucket

func GetBucket(db *sql.DB, bucketID string) (*Bucket, error)

GetBucket retrieves a bucket by ID This should return a new bucket instance

type Object

type Object struct {
	ID            string
	BucketID      string
	Filename      string
	LatestVersion string
}

Object represents a stored file

type ObjectType

type ObjectType struct {
	ObjectID      string
	Filename      string
	LatestVersion string
}

ObjectType represents a miniature singleton of an object

func ListObjects

func ListObjects(db *sql.DB, bucketID string) ([]ObjectType, error)

ListObjects lists all objects in a bucket

type VersionMetadata

type VersionMetadata struct {
	BucketID       string            `json:"bucket_id"`
	ObjectID       string            `json:"object_id"`
	VersionID      string            `json:"file_version"`
	Filename       string            `json:"filename"`
	Filesize       string            `json:"filesize"`
	Format         string            `json:"file_formart"`
	CreationDate   string            `json:"creation_date"`
	Data           []byte            `json:"data"`
	ShardLocations map[string]string `json:"shard_locations"`
	Proofs         map[string]string `json:"proofs"`
}

VersionMetadata represents the metadata for a version

func GetObjectMetadata

func GetObjectMetadata(db *sql.DB, objectID, versionID string) (*VersionMetadata, error)

GetObjectMetadata retrieves metadata for an object version

Jump to

Keyboard shortcuts

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