Documentation ¶
Index ¶
- Variables
- func Join(parts ...string) string
- func ValidatePath(path string) error
- type DeleteFolderOptions
- type File
- type FileMetadata
- type FileStorage
- type GetFileOptions
- type ListOptions
- type ListResponse
- type MockFileStorage
- func (_m *MockFileStorage) CreateFolder(ctx context.Context, path string) error
- func (_m *MockFileStorage) Delete(ctx context.Context, path string) error
- func (_m *MockFileStorage) DeleteFolder(ctx context.Context, path string, options *DeleteFolderOptions) error
- func (_m *MockFileStorage) Get(ctx context.Context, path string, options *GetFileOptions) (*File, bool, error)
- func (_m *MockFileStorage) List(ctx context.Context, folderPath string, paging *Paging, options *ListOptions) (*ListResponse, error)
- func (_m *MockFileStorage) Upsert(ctx context.Context, command *UpsertFileCommand) error
- type Paging
- type PathFilter
- type UpsertFileCommand
Constants ¶
This section is empty.
Variables ¶
var ( ErrRelativePath = errors.New("path cant be relative") ErrNonCanonicalPath = errors.New("path must be canonical") ErrPathTooLong = errors.New("path is too long") ErrInvalidCharacters = errors.New("path contains unsupported characters") ErrPathEndsWithDelimiter = errors.New("path can not end with delimiter") ErrPathPartTooLong = errors.New("path part is too long") ErrEmptyPathPart = errors.New("path can not have empty parts") Delimiter = "/" DirectoryMimeType = "directory" )
Functions ¶
func ValidatePath ¶
Types ¶
type DeleteFolderOptions ¶
type DeleteFolderOptions struct { // Force if set to true, the `deleteFolder` operation will delete the selected folder together with all the nested files & folders Force bool // AccessFilter must match all the nested files & folders in order for the `deleteFolder` operation to succeed // The access check is not performed if `AccessFilter` is nil AccessFilter PathFilter }
type File ¶
type File struct { Contents []byte FileMetadata }
type FileMetadata ¶
type FileStorage ¶
type FileStorage interface { Get(ctx context.Context, path string, options *GetFileOptions) (*File, bool, error) Delete(ctx context.Context, path string) error Upsert(ctx context.Context, command *UpsertFileCommand) error // List lists only files without content by default List(ctx context.Context, folderPath string, paging *Paging, options *ListOptions) (*ListResponse, error) CreateFolder(ctx context.Context, path string) error DeleteFolder(ctx context.Context, path string, options *DeleteFolderOptions) error // contains filtered or unexported methods }
func NewCdkBlobStorage ¶
func NewCdkBlobStorage(log log.Logger, bucket *blob.Bucket, rootFolder string, filter PathFilter) FileStorage
func NewDbStorage ¶
func NewDbStorage(log log.Logger, db db.DB, filter PathFilter, rootFolder string) FileStorage
type GetFileOptions ¶
type GetFileOptions struct { // WithContents if set to false, the `Get` operation will return just the file metadata. Default is `true` WithContents bool }
type ListOptions ¶
type ListOptions struct { Recursive bool WithFiles bool WithFolders bool WithContents bool Filter PathFilter }
type ListResponse ¶
func (*ListResponse) String ¶
func (r *ListResponse) String() string
type MockFileStorage ¶
MockFileStorage is an autogenerated mock type for the FileStorage type
func (*MockFileStorage) CreateFolder ¶
func (_m *MockFileStorage) CreateFolder(ctx context.Context, path string) error
CreateFolder provides a mock function with given fields: ctx, path
func (*MockFileStorage) Delete ¶
func (_m *MockFileStorage) Delete(ctx context.Context, path string) error
Delete provides a mock function with given fields: ctx, path
func (*MockFileStorage) DeleteFolder ¶
func (_m *MockFileStorage) DeleteFolder(ctx context.Context, path string, options *DeleteFolderOptions) error
DeleteFolder provides a mock function with given fields: ctx, path, options
func (*MockFileStorage) Get ¶
func (_m *MockFileStorage) Get(ctx context.Context, path string, options *GetFileOptions) (*File, bool, error)
Get provides a mock function with given fields: ctx, path, options
func (*MockFileStorage) List ¶
func (_m *MockFileStorage) List(ctx context.Context, folderPath string, paging *Paging, options *ListOptions) (*ListResponse, error)
List provides a mock function with given fields: ctx, folderPath, paging, options
func (*MockFileStorage) Upsert ¶
func (_m *MockFileStorage) Upsert(ctx context.Context, command *UpsertFileCommand) error
Upsert provides a mock function with given fields: ctx, command
type PathFilter ¶
type PathFilter interface { IsAllowed(path string) bool ToString() string // contains filtered or unexported methods }
func NewAllowAllPathFilter ¶
func NewAllowAllPathFilter() PathFilter
func NewAndPathFilter ¶
func NewAndPathFilter(filters ...PathFilter) PathFilter
func NewDenyAllPathFilter ¶
func NewDenyAllPathFilter() PathFilter
func NewPathFilter ¶
func NewPathFilter(allowedPrefixes []string, allowedPaths []string, disallowedPrefixes []string, disallowedPaths []string) PathFilter
NewPathFilter factory function for a tree-based PathFilter `nil` and empty arrays are treated in a different way. The PathFilter will not perform checks associated with a `nil` array, examples:
- `allowedPrefixes` & `allowedPaths` are nil -> all paths are allowed (unless included in `disallowedX` arrays)
- `allowedPrefixes` & `allowedPaths` are both empty -> no paths are allowed, regardless of what is inside `disallowedX` arrays
- `allowedPrefixes` is nil, `allowedPaths` is not nil. -> only paths specified in `allowedPaths` are allowed (unless included in `disallowedX` arrays)
type UpsertFileCommand ¶
type UpsertFileCommand struct { Path string MimeType string CacheControl string ContentDisposition string // Contents of an existing file won't be modified if cmd.Contents is nil Contents []byte // Properties of an existing file won't be modified if cmd.Properties is nil Properties map[string]string }