-
Notifications
You must be signed in to change notification settings - Fork 2
Home
There are two config files that contain Storj network and framework connection information. The tool is designed so you can specify a config file as part of your tooling/workflow.
Inside the ./config
directory there is a local.json
file, with following information about your framework(local file in this case) instance:
-
path
- Path to local file
Inside the ./config
directory a storj_config.json
file, with Storj network configuration information in JSON format:
-
apiKey
- API Key created in Storj Satellite GUI(mandatory) -
satelliteURL
- Storj Satellite URL(mandatory) -
encryptionPassphrase
- Storj Encryption Passphrase(mandatory) -
bucketName
- Name of the bucket to upload data into(mandatory) -
uploadPath
- Path on Storj Bucket to store data (optional) or "/" (mandatory) -
serializedAccess
- Serialized access shared while uploading data used to access bucket without API Key (mandatory while using accesskey flag) -
allowDownload
- Set true to create serialized access with restricted download (mandatory while using share flag) -
allowUpload
- Set true to create serialized access with restricted upload (mandatory while using share flag) -
allowList
- Set true to create serialized access with restricted list access -
allowDelete
- Set true to create serialized access with restricted delete -
notBefore
- Set time that is always before notAfter -
notAfter
- Set time that is always after notBefore
Back-up is uploaded by streaming to the Storj network.
The following flags can be used with the store
command:
-
accesskey
- Connects to the Storj network using a serialized access key instead of an API key, satellite url and encryption passphrase. -
shared
- Generates a restricted shareable serialized access with the restrictions specified in the Storj configuration file.
Once you have built the project you can run the following:
$ ./connector-framework --help
$ ./connector-framework --version
$ ./connector-framework store --local <path_to_local_config_file> --storj <path_to_storj_config_file>
$ ./connector-framework store --accesskey
Upload back-up data to Storj and generate a Shareable Access Key based on restrictions in storj_config.json
$ ./connector-framework store --share
The project has been tested on the following operating systems:
* Windows
* Version: 10 Pro
* Processor: Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz 2.00GHz
* macOS Catalina
* Version: 10.15.4
* Processor: 2.5 GHz Dual-Core Intel Core i5
* ubuntu
* Version: 16.04 LTS
* Processor: AMD A6-7310 APU with AMD Radeon R4 Graphics × 4
func ConnectToLocalDisk(configLocalFile ConfigLocalFile) *os.File
ConnectToLocalDisk takes the configuration object as argument and returns the reader of the source file to be uploaded. Function name and implementation can be changed to connect to the required source instance and return the required handle/reader.
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 ShareAccess(access *uplink.Access, configStorj ConfigStorj)
ShareAccess generates and prints the shareable serialized access as per the restrictions provided by the user.
func UploadData(project *uplink.Project, configStorj ConfigStorj, uploadFileName string, fileReader *os.File)
UploadData uploads the backup file to storj network. Parameters can be changed as per the requirement. If reader/handle is not passed as an argument to call the function, add the corresponding code snippet to create one. Remember to close the reader after the upload is committed.
type ConfigLocalFile struct {
Path string `json:"path"`
}
ConfigLocalFile stores the local file path. Change the strcuture name and definition to store the configurations and credentials of whatever the source being used.
type ConfigStorj struct {
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.
The following cis the tutorial to create your own connector:
- Change the name of the source config file to the source name and add the required configurations and credentials to it or you can simply create your own source configuration file.
Change the name of the file to source name and make the following amendments:
- Change the source configuration structure to store the specified source configurations.
- Add print statements in the Load
- Add the code to connect to source and create an instance, create/fetch back-up data or files, and create a reader to the backup file/data.
Following changes need to be made in the store.go file:
- Change the corresponding variable and flag names.
- Process the upload file name to convert to a standard and less complex form, if required.
- Made changes in the code fragment calling the upload function as per the arguments you wish to pass. Only the reader and file path/name arguments should be changed.
The following changes need to be made only in the upload function:
- Change the arguments in the function definition as per the arguments passed from store.go.
- If reader is not passed as an argument to call the upload function, add the code fragment to create one. Remember to close the reader after the upload is committed.
- In case you want to implement section uploading, the corresponding code snippet has been provided in a commented block for the same. Uncomment the same and use it for the purpose.
- For uplaoding a byte array(buffer), a commented block has been provided for that also. Uncomment the same and use it for the purpose.