fsbackend

package
v0.0.0-...-91649ba Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2020 duyanghao

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RootDirectory string `yaml:"rootDirectory"` // filesystem root directory
}

Config defines filesystem specific parameters and authetication credentials

type Option

type Option func(storage *Storage)

Option allows setting optional Client parameters.

func WithS3

func WithS3(config Config) Option

WithS3 configures a Storage with a custom config implementation.

type Storage

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

Client implements a backend.Storage for FileSystem.

func NewStorage

func NewStorage(
	config Config, opts ...Option) (*Storage, error)

NewStorage creates a new Storage for file system.

func (*Storage) CreateWithMetaInfo

func (fs *Storage) CreateWithMetaInfo(name string, info *metainfo.MetaInfo) error

Create creates name and returns io.Writer

func (*Storage) Delete

func (fs *Storage) Delete(name string) error

Delete removes name file

func (*Storage) Download

func (fs *Storage) Download(name string) ([]byte, error)

Download reads file content from name

func (*Storage) GetDataDir

func (fs *Storage) GetDataDir() string

func (*Storage) GetFilePath

func (fs *Storage) GetFilePath(id string) string

GetFilePath returns data file path

func (*Storage) GetTorrentDir

func (fs *Storage) GetTorrentDir() string

func (*Storage) GetTorrentFilePath

func (fs *Storage) GetTorrentFilePath(id string) string

GetTorrentFilePath returns torrent file path

func (*Storage) List

func (fs *Storage) List(prefix string) ([]*backend.FileInfo, error)

List lists fileEntries whose names start with prefix.

func (*Storage) Stat

func (fs *Storage) Stat(name string) (*backend.FileInfo, error)

Stat is useful when we need to quickly know if a blob exists (and maybe some basic information about it), without downloading the entire blob, which may be very large.

func (*Storage) Upload

func (fs *Storage) Upload(name string, data []byte) error

Upload writes data to name file

Jump to

Keyboard shortcuts

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