Documentation ¶
Index ¶
- Constants
- type AccessToken
- type CreateStorageAccessTokenRequest
- type FileMetadata
- type FileMetadataWithDBKey
- type Interface
- type IntrospectAccessTokenResponse
- type Storage
- func (s *Storage) CanAccess(token string) (bool, AccessToken, error)
- func (s *Storage) CreateStorageAccessToken(w http.ResponseWriter, r *http.Request)
- func (s *Storage) CreateSubfolders() (string, error)
- func (s *Storage) DeleteFileFromDB(key string) error
- func (s *Storage) DeleteFileMetadata(fileHash, peerID string) error
- func (s *Storage) Enabled() bool
- func (s *Storage) ExportFiles() ([]FileMetadataWithDBKey, error)
- func (s *Storage) GetFileMetadata(fileHash string, peerID string) (FileMetadata, error)
- func (s *Storage) GetTotalFilesStored() uint64
- func (s *Storage) HandleIncomingFileUploads(stream network.Stream)
- func (s *Storage) ImportFiles(importedFile string) (int, error)
- func (s *Storage) IntrospectAccessToken(w http.ResponseWriter, r *http.Request)
- func (s *Storage) ListFiles(currentPage, pageSize int, order string) ([]FileMetadataWithDBKey, uint64, error)
- func (s *Storage) SaveFileMetadata(fileHash, peerID string, metadata FileMetadata) error
- func (s *Storage) SaveToken(token AccessToken) error
- func (s *Storage) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Storage) SetEnabled(val bool)
- func (s *Storage) StoragePath() string
Constants ¶
const ( // AdminAccess represents full access. AdminAccess = "admin" // UserAccess represents privilege access. UserAccess = "user" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { AccessType string `json:"access_type"` Token string `json:"token"` ExpiresAt int64 `json:"expires_at"` }
AccessToken represents an access token.
type CreateStorageAccessTokenRequest ¶ added in v1.3.0
type CreateStorageAccessTokenRequest struct {
UserAccessType string `json:"user_access_type"`
}
CreateStorageAccessTokenRequest represents the request for creating a new storage token.
type FileMetadata ¶
type FileMetadata struct { FileName string `json:"file_name"` MerkleRootHash string `json:"merkle_root_hash"` Hash string `json:"hash"` FilePath string `json:"file_path"` Size int64 `json:"size"` RemotePeer string `json:"remote_peer"` Timestamp int64 `json:"timestamp"` FeesPerByte string `json:"fees_per_byte"` PublicKeyOwner string `json:"public_key_owner"` }
FileMetadata holds the metadata for a file.
type FileMetadataWithDBKey ¶ added in v1.1.29
type FileMetadataWithDBKey struct { FileMetadata Key string `json:"key"` FileExistsOnNode bool `json:"file_exists_on_node"` }
FileMetadataWithDBKey holds the file metatada and the key.
type Interface ¶
type Interface interface { StoragePath() string Enabled() bool SetEnabled(val bool) CreateSubfolders() (string, error) SaveToken(token AccessToken) error SaveFileMetadata(fileHash, peerID string, metadata FileMetadata) error DeleteFileMetadata(fileHash, peerID string) error GetFileMetadata(fileHash string, peerID string) (FileMetadata, error) CanAccess(token string) (bool, AccessToken, error) HandleIncomingFileUploads(stream network.Stream) ListFiles(currentPage, pageSize int, order string) ([]FileMetadataWithDBKey, uint64, error) DeleteFileFromDB(key string) error ExportFiles() ([]FileMetadataWithDBKey, error) ImportFiles(string) (int, error) }
Interface defines the functionalities of the storage engine.
type IntrospectAccessTokenResponse ¶ added in v1.3.0
type IntrospectAccessTokenResponse struct { AccessToken AccessToken `json:"access_token"` AllowFeesOverride bool `json:"allow_fees_override"` Platform string `json:"platform"` FeesPerByte string `json:"fees_per_byte"` PublicKey string `json:"public_key"` StorageCapacity uint64 `json:"storage_capacity"` PeerID string `json:"storage_provider_peer_addr"` UptimeSeconds int64 `json:"uptime_seconds"` }
IntrospectAccessTokenResponse contains the token info and some info about the storage node.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage represents the storage engine and the metadata.
func New ¶
func New(db database.Database, storagePath string, enabled bool, adminToken string, merkleTreeTotalSegments int, peerID string, allowFeesOverride bool, publicKey, feesPerByte string, uptime int64) (*Storage, error)
New creates a new storage instance.
func (*Storage) CanAccess ¶
func (s *Storage) CanAccess(token string) (bool, AccessToken, error)
CanAccess authorizes access.
func (*Storage) CreateStorageAccessToken ¶ added in v1.3.0
func (s *Storage) CreateStorageAccessToken(w http.ResponseWriter, r *http.Request)
CreateStorageAccessToken creates a storage access token.
func (*Storage) CreateSubfolders ¶
CreateSubfolders creates sub folders with current date inside the data directory.
func (*Storage) DeleteFileFromDB ¶ added in v1.1.29
DeleteFileFromDB deletes a file from local db.
func (*Storage) DeleteFileMetadata ¶ added in v1.2.1
DeleteFileMetadata deletes the metadata from the db.
func (*Storage) ExportFiles ¶ added in v1.2.1
func (s *Storage) ExportFiles() ([]FileMetadataWithDBKey, error)
ExportFiles gets all the uploaded files.
func (*Storage) GetFileMetadata ¶
func (s *Storage) GetFileMetadata(fileHash string, peerID string) (FileMetadata, error)
GetFileMetadata gets a file's metadata in the database.
func (*Storage) GetTotalFilesStored ¶ added in v1.1.20
GetTotalFilesStored returns the total number of files stored on this node.
func (*Storage) HandleIncomingFileUploads ¶ added in v1.1.16
ServeHTTP handles file uploading.
func (*Storage) ImportFiles ¶ added in v1.2.1
ImportFiles gets all the uploaded files list
func (*Storage) IntrospectAccessToken ¶ added in v1.3.0
func (s *Storage) IntrospectAccessToken(w http.ResponseWriter, r *http.Request)
IntrospectAccessToken returns the payload of an access token.
func (*Storage) ListFiles ¶ added in v1.1.19
func (s *Storage) ListFiles(currentPage, pageSize int, order string) ([]FileMetadataWithDBKey, uint64, error)
ListFiles the uploaded files.
func (*Storage) SaveFileMetadata ¶
func (s *Storage) SaveFileMetadata(fileHash, peerID string, metadata FileMetadata) error
SaveFileMetadata saves a file's metadata in the database.
func (*Storage) SaveToken ¶
func (s *Storage) SaveToken(token AccessToken) error
SaveToken saves an access token into the database.
func (*Storage) ServeHTTP ¶
func (s *Storage) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles file uploading.
func (*Storage) SetEnabled ¶
SetEnabled return if storage functionality is enabled.
func (*Storage) StoragePath ¶
StoragePath return the storage path.