- chainstorage-cli is the command line application to interact with rest api SDK of chain strorage.
- CAR import support: import CAR-archived content with custom DAGs directly to the Cluster.
go install github.com/paradeum-team/chainstorage-cli@latest
The chainstorage-cli tool provides various commands to interact with the system. Use the following commands to perform specific operations:
config
: Manage configurationget
: Get objecthelp
: Get help for any commandimport
: Import CAR filelog
: Manage and display logs of the running daemonls
: List links from an object or bucketmb
: Create a new bucketput
: Upload a file or folderrb
: Remove a bucketrm
: Delete objects or clear bucketrn
: Rename an objectversion
: Show version information
To execute a command, use the following format:
command [flags] [arguments]
For example, to create a new bucket, use the following command:
gcscmd mb [bucket-name]
Replace [bucket-name]
with the desired name for the new bucket.
The config
command allows you to manage the configuration of the application.
gcscmd config
To display the current configuration settings, use the following command:
gcscmd config
The get
command allows you to retrieve an object from the system. Use the following syntax:
gcscmd get cs://<BUCKET> [--name=<name>] [--cid=<cid>] [--downloadFolder=<downloadfolder>] [flags]
Replace <BUCKET>
with the name of the bucket where the object is located. You can optionally specify the name or CID of the object using the --name
or --cid
flags, respectively.
-c, --cid <cid>
: The CID of the object you want to retrieve.-n, --name <name>
: The name of the object you want to retrieve.-d, --downloadFolder <downloadfolder>
: The folder of download.
To get an object named "example.txt" from the bucket "my-bucket", use the following command:
gcscmd get cs://my-bucket --name=example.txt
This will retrieve the "example.txt" object from the "my-bucket" bucket.
Use the get
command to retrieve objects from the system by specifying the bucket and optionally providing the name or CID of the object you want to retrieve.
The help
command provides detailed help information for any command in the application.
gcscmd help [command]
Replace [command]
with the name of the command for which you need help.
The import
command allows you to import a CAR file into the system. Use the following syntax:
gcscmd import <CARFILE> cs://<BUCKET>
To import a CAR file into a bucket, use the following command:
gcscmd import CARFILE cs://BUCKET
Replace CARFILE
with the path to the CAR file you want to import, and BUCKET
with the name of the bucket where you want to import the file.
This command will import the specified CAR file into the specified bucket.
The log
command allows you to manage and display logs. Use the following syntax:
gcscmd log <level>
To manage and show logs of the running daemon, use the following command:
gcscmd log <level>
Replace <level>
with the desired log level, such as trace
, debug
, info
, warn
, or error
.
This command will manage and display logs of the specified log level.
The ls
command allows you to list links from an object or bucket. Use the following syntax:
gcscmd ls [cs://<BUCKET>] [--name=<name>] [--cid=<cid>] [--Offset=<Offset>]
cs://BUCKET
: The name of the bucket you want to get.
-c, --cid <cid>
: Specifies the CID of the object to list links from.-n, --name <name>
: Specifies the name of the object to list links from.-o, --offset <offset>
: Specifies the list offset, i.e., the number of links to skip before starting the listing. The default offset is 10.
To list all buckets, use the following command:
gcscmd ls --offset <offset>
Replace <offset>
with the desired list offset value.
To list links from an object or bucket, use the following command:
gcscmd ls cs://<BUCKET> --cid <cid> --offset <offset>
Replace <BUCKET>
with the name of the bucket, <cid>
with the CID of the object, and <offset>
with the desired list offset value.
Alternatively, you can specify the object name using the --name
flag:
gcscmd ls cs://<BUCKET> --name <name> --offset <offset>
Replace <name>
with the name of the object and <offset>
with the desired list offset value.
The mb
command allows you to create a new bucket. Use the following syntax:
gcscmd mb cs://<BUCKET> [--storageNetworkCode=<storageNetworkCode>] [--bucketPrincipleCode=<bucketPrincipleCode>]
Replace <BUCKET>
with the desired name for the new bucket.
-s, --storageNetworkCode
: Optional. The storage network code for the bucket. Default: 10001.-b, --bucketPrincipleCode
: Optional. The bucket principle code. Default: 10001.
Create a bucket named "my-bucket" with default storage network and bucket principle codes:
gcscmd mb cs://my-bucket
Create a bucket named "my-bucket" with custom storage network and bucket principle codes:
gcscmd mb cs://my-bucket --storageNetworkCode=10001 --bucketPrincipleCode=10001
The put
command allows you to upload a file or folder to the system. Use the following syntax:
gcscmd put <FILE[/DIR...]> cs://<BUCKET> [flags]
FILE[/DIR...]
: The path to the file or folder you want to upload.cs://BUCKET
: The target bucket where the file or folder should be uploaded.
-c, --carFile
: Optional. Specify a CAR file to upload.
Upload a single file:
gcscmd put /path/to/file.txt cs://my-bucket
Upload a folder:
gcscmd put /path/to/folder cs://my-bucket
Upload a file using a CAR file:
gcscmd put --carFile=/path/to/file.car cs://my-bucket
The rb
command allows you to remove a bucket from the system. Use the following syntax:
gcscmd rb cs://<BUCKET> [--force]
cs://BUCKET
: The name of the bucket you want to remove.
-f, --force
: Optional. If the bucket contains objects, adding this flag will prompt for confirmation before deletion.
Remove a bucket:
gcscmd rb cs://my-bucket
Remove a bucket with confirmation for deletion if it contains objects:
gcscmd rb cs://my-bucket --force
The rm
command allows you to delete objects, or empty a bucket by removing all objects within it. Use the following syntax:
gcscmd rm cs://<BUCKET> [--name=<name>] [--cid=<cid>] [--force]
cs://BUCKET
: The name of the bucket you want to empty.
-n, --name
: Optional. Specify the name of a specific object to remove.-c, --cid
: Optional. Specify the CID (Content Identifier) of a specific object to remove.-f, --force
: Optional. Adding this flag will prompt for confirmation before emptying the bucket.
Empty a bucket:
gcscmd rm cs://my-bucket
Empty a bucket and confirm deletion for each object:
gcscmd rm cs://my-bucket --force
Empty a bucket and remove a specific object:
gcscmd rm cs://my-bucket --name=my-object
The rn
command allows you to rename an object. Use the following syntax:
gcscmd rn cs://<BUCKET> <--name=<name>> [--cid=<cid>] <--rename=<rename>> [--force]
cs://BUCKET
: The name of the bucket where the object is located.
-n, --name
: Specify the current name of the object.-c, --cid
: Optional. Specify the CID (Content Identifier) of the object.-r, --rename
: Specify the new name for the object.-f, --force
: Optional. Adding this flag will prompt for confirmation if there are any filename conflicts during the renaming process.
Rename an object:
gcscmd rn cs://my-bucket --name=my-object --rename=new-object
Rename an object using its CID:
gcscmd rn cs://my-bucket --cid=<object-cid> --rename=new-object
Rename an object and force overwrite if there are conflicts:
gcscmd rn cs://my-bucket --name=my-object --rename=new-object --force
The version
command displays information about the current version of IPFS.
gcscmd version
To show the IPFS version information, use the following command:
gcscmd version
This will display the version number information about IPFS.
The CLI tool supports custom configuration to modify its behavior. Configuration can be specified using a TOML (Tom's Obvious, Minimal Language) file.
The configuration file is a TOML file that contains key-value pairs representing various configuration options. By default, the CLI tool looks for a configuration file named config.toml
in the current working directory. You can specify a different file using the --config
flag.
Here is an example of a configuration file (config.toml
) with available options:
[cli]
ipfsGateway = "test-ipfs-gateway.netwarps.com/ipfs/"
useHttpsProtocol = true
bucketPrefix = 'cs://'
listOffset = 20
cleanTmpData = true
maxRetries = 3
retryDelay = 3
[sdk]
defaultRegion = 'hk-1'
timeZone = 'UTC +08:00'
chainStorageApiEndpoint = 'http://127.0.0.1:8821'
useHttpsProtocol = true
carFileWorkPath = './tmp/carfile'
carFileShardingThreshold = 46137344
chainStorageApiToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
httpRequestUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
httpRequestOvertime = 30
carVersion = 1
[logger]
logPath = './logs'
mode = 'debug'
level = 'info'
isOutPutFile = true
maxAgeDay = 7
rotationTime = 1
useJson = true
loggerFile= 'chainstorage-cli-log'
The CLI configuration allows you to specify various settings related to the tool's functionality.
- Description: The IPFS gateway URL to use for fetching IPFS content.
- Type: String
- Default Value:
test-ipfs-gateway.netwarps.com/ipfs/
- Description: Indicates whether to use HTTPS protocol.
- Type: Boolean
- Default Value:
true
- Description: The prefix to add to bucket names.
- Type: String
- Default Value:
cs://
- Description: The number of items to skip when listing objects.
- Type: Integer
- Default Value:
20
- Description: Indicates whether to clean temporary data after each operation.
- Type: Boolean
- Default Value:
true
- Description: The maximum number of retries for failed operations.
- Type: Integer
- Default Value:
3
- Description: The delay (in seconds) between retry attempts.
- Type: Integer
- Default Value:
3
The SDK configuration allows you to specify various settings related to the SDK's functionality.
- Description: The default region for SDK operations.
- Type: String
- Default Value:
hk-1
- Description: The time zone used for SDK operations.
- Type: String
- Default Value:
UTC +08:00
- Description: The API endpoint for the Chain Storage service.
- Type: String
- Default Value:
http://127.0.0.1:8821
- Description: Indicates whether to use HTTPS protocol.
- Type: Boolean
- Default Value:
true
- Description: The working directory for CAR files.
- Type: String
- Default Value:
./tmp/carfile
- Description: The threshold (in bytes) for CAR file sharding.
- Type: Integer
- Default Value:
46137344
- Description: The API token for accessing the Chain Storage service.
- Type: String
- Default Value:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
- Description: The user agent to use in HTTP requests.
- Type: String
- Default Value:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...
- Description: The timeout (in seconds) for HTTP requests.
- Type: Integer
- Default Value:
30
- Description: The version of CAR files.
- Type: Integer
- Default Value:
1
The logger configuration allows you to specify various settings related to logging.
- Description: The path where log files will be stored.
- Type: String
- Default Value:
./logs
- Description: The mode of the logger.
- Type: String
- Default Value:
debug
- Description: The logging level.
- Type: String
- Default Value:
info
- Description: Indicates whether logging should be output to a file.
- Type: Boolean
- Default Value:
true
- Description: The maximum age of log files in days before they are rotated.
- Type: Integer
- Default Value:
7
- Description: The time interval (in days) at which log files should be rotated.
- Type: Integer
- Default Value:
1
- Description: Indicates whether logging should be output in JSON format.
- Type: Boolean
- Default Value:
true
- Description: The name of the log file.
- Type: String
- Default Value:
chainstorage-cli-log