cmd

package
v0.0.0-...-be207ed Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DownCmd = &cobra.Command{
	Use:   "download",
	Short: "Command to download data from storj V3 network.",
	Long:  `Command to download data from the Storj Bucket using the Hash.`,
	Run:   storjDownload,
}

DownCmd represents the download command.

Functions

func ConnectToIPFSForDownload

func ConnectToIPFSForDownload(hash string, hostName string, port string) *bytes.Reader

ConnectToIPFSForDownload will connect to a IPFS instance, based on the hash name of file on IPFS. It returns a reference to an io.Reader with IPFS instance information

func ConnectToIpfs

func ConnectToIpfs(configIpfs ConfigIpfs) *shell.Shell

ConnectToIpfs will connect to a IPFS instance, based on the read property from an external file. It returns a reference to an io.Reader with IPFS instance information.

func ConnectToStorj

func ConnectToStorj(fullFileName string, configStorj ConfigStorj, accesskey bool) (*uplink.Access, *uplink.Project)

ConnectToStorj reads Storj configuration from given file and connects to the desired Storj network. It then reads data property from an external file.

func CreateCID

func CreateCID(sh *shell.Shell, data []byte) string

CreateCID will connect to a IPFS instance based on the read property from an external file. It returns Created CID.

func DownloadData

func DownloadData(project *uplink.Project, downloadConfigStorj DownloadConfigStorj, readFile *bytes.Reader)

DownloadData function downloads the data from storj bucket after upload to verify data is uploaded successfully.

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetReader

func GetReader(sh *shell.Shell, configIpfs ConfigIpfs) io.ReadCloser

GetReader returns a Reader of corresponding file whose path is specified. io.ReadCloser type of object returned is used to perform transfer of file to Storj.

func GetReaderDownload

func GetReaderDownload(sh *shell.Shell, hash string) *bytes.Reader

GetReaderDownload returns a Reader of corresponding file whose path is specified. io.ReadCloser type of object returned is used to perform transfer of file to Storj.

func ShareAccess

func ShareAccess(access *uplink.Access, configStorj ConfigStorj)

ShareAccess generates and prints the shareable serialized access as per the restrictions provided by the user.

func UploadData

func UploadData(project *uplink.Project, configStorj ConfigStorj, uploadFileName string, reader io.Reader)

UploadData uploads the backup file to storj network.

Types

type ConfigIpfs

type ConfigIpfs struct {
	HostName  string `json:"hostName"`
	Port      string `json:"port"`
	Path      string `json:"path"`
	ChunkSize string `json:"chunkSize"`
}

ConfigIpfs defines the variables and types.

func LoadIpfsProperty

func LoadIpfsProperty(fullFileName string) ConfigIpfs

LoadIpfsProperty reads and parses the JSON file that contain a IPFS instance's property. and returns all the properties as an object.

type ConfigStorj

type ConfigStorj struct {
	Key                  string `json:"key"`
	APIKey               string `json:"apikey"`
	Satellite            string `json:"satellite"`
	Bucket               string `json:"bucket"`
	UploadPath           string `json:"uploadPath"`
	EncryptionPassphrase string `json:"encryptionpassphrase"`
	SerializedAccess     string `json:"serializedAccess"`
	AllowDownload        string `json:"allowDownload"`
	AllowUpload          string `json:"allowUpload"`
	AllowList            string `json:"allowList"`
	AllowDelete          string `json:"allowDelete"`
	NotBefore            string `json:"notBefore"`
	NotAfter             string `json:"notAfter"`
}

ConfigStorj depicts keys to search for within the stroj_config.json file.

func LoadStorjConfiguration

func LoadStorjConfiguration(fullFileName string) ConfigStorj

LoadStorjConfiguration reads and parses the JSON file that contain Storj configuration information.

type DownloadConfigStorj

type DownloadConfigStorj struct {
	Hash         string `json:"hash"`
	DownloadPath string `json:"downloadPath"`
	Key          string `json:"key"`
}

DownloadConfigStorj structure to store data from json file

func LoadStorjDownloadConfiguration

func LoadStorjDownloadConfiguration(fullFileName string) DownloadConfigStorj

LoadStorjDownloadConfiguration reads and parses the JSON file that contain Storj configuration information.

Jump to

Keyboard shortcuts

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