storage

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package storage provides data storage for the extension and user specific data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	Dir string // path to the data storage directory
	// contains filtered or unexported fields
}

Dir manages data storage for the extension and user specific data on the local filesystem.

func (*Dir) Cleanup

func (d *Dir) Cleanup() error

Cleanup removes the temporary directory if Make was called with a non empty dir argument. It is named as Cleanup because it can be used for other features in the future.

func (*Dir) Make

func (d *Dir) Make(tmpDir string, dir any) error

Make creates a new temporary directory in tmpDir, and stores the path to the directory in the Dir field. When the dir argument is not empty, no directory will be created and it will not be deleted if Cleanup is called.

type LocalFilePersister added in v1.4.0

type LocalFilePersister struct{}

LocalFilePersister will persist files to the local disk.

func (*LocalFilePersister) Persist added in v1.4.0

func (l *LocalFilePersister) Persist(_ context.Context, path string, data io.Reader) (err error)

Persist will write the contents of data to the local disk on the specified path. TODO: we should not write to disk here but put it on some queue for async disk writes.

type PresignedURLResponse added in v1.8.0

type PresignedURLResponse struct {
	Service string `json:"service"`
	URLs    []struct {
		Name         string            `json:"name"`
		PresignedURL string            `json:"pre_signed_url"` //nolint:tagliatelle
		Method       string            `json:"method"`
		FormFields   map[string]string `json:"form_fields"` //nolint:tagliatelle
	} `json:"urls"`
}

PresignedURLResponse holds the response from a presigned generation request.

type RemoteFilePersister added in v1.4.0

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

RemoteFilePersister is to be used when files created by the browser module need to be uploaded to a remote location. This uses a presignedURLRequestURL to retrieve one presigned URL. The presigned url is used to upload the file to the remote location.

func NewRemoteFilePersister added in v1.4.0

func NewRemoteFilePersister(
	presignedURLRequestURL string,
	headers map[string]string,
	basePath string,
) *RemoteFilePersister

NewRemoteFilePersister creates a new instance of RemoteFilePersister.

func (*RemoteFilePersister) Persist added in v1.4.0

func (r *RemoteFilePersister) Persist(ctx context.Context, path string, data io.Reader) (err error)

Persist will upload the contents of data to a remote location.

Jump to

Keyboard shortcuts

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