file

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name       string `json:"name"`
	IsFolder   bool   `json:"isFolder"`
	URI        string `json:"uri"`
	ChildNodes []File `json:"childNodes"`
}

File represents a file or directory item.

type Option

type Option func(*options)

Option is a function that modifies options

func WithOnlyFolder

func WithOnlyFolder(onlyFolder bool) Option

WithOnlyFolder sets the onlyFolder option

func WithURI

func WithURI(uri string) Option

WithURI sets the URI for the options

type Service

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

Service is our abstraction that uses github.com/viant/afs to list files from a root.

func New

func New(root string, options ...storage.Option) *Service

New creates a new Service.

func (*Service) Download

func (f *Service) Download(ctx context.Context, uri string) ([]byte, error)

Download downloads a file from the specified uri.

func (*Service) Exists

func (f *Service) Exists(ctx context.Context, requestedPath string) (bool, error)

Exists checks if a file exists at the specified uri.

func (*Service) List

func (f *Service) List(ctx context.Context, opts ...Option) ([]File, error)

List returns the files and directories at requestedPath (relative to Service.root).

func (*Service) Upload

func (f *Service) Upload(ctx context.Context, uri string, payload []byte) error

Upload uploads a file to the specified uri.

Jump to

Keyboard shortcuts

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