Configure BOSCLI
General configuration
Configure a CLI environment supporting Chinese display
If you need to configure a CLI environment that supports Chinese display, execute the following command:
$ export LANG=en_US.UTF-8
Note: You can first run the
$ localecommand to check the language support status of the current environment. If it is notLANG=en_US.UTF-8, you can execute the above command to modify it.
Configure AK/SK, Region and Host information
Before using the BOS CLI tool, it is recommended to first configure the Access Key, Secure Key, Region, and Host. You can set AK, SK, Region, and Host details using the -c/--configure option.
1$ bce -c [<conf-path>]
2$ BOS Access Key ID [None]: Enter Your AK
3$ BOS Secret Access Key [None]: Enter Your SK
4$ BCE Security Token [None]: Enter Your Security Token
5$ Default region name [bj]: Enter Your region
6$ Default domain [bj.bcebos.com]: Enter Your host
Description:
<conf-path>is a local file directory. When a user has multiple Baidu AI Cloud accounts, specifying<conf-path>allows configuration files for different accounts to be written to different directories. When executing commands, you can specify the directory to select the configuration of the corresponding account.- If
<conf-path>is not specified, after configuration is completed, the CLI will automatically write the configuration file to the current user’s home directory~/.bce; if<conf-path>is specified, the configuration file will be automatically written to the specified directory.- Even if you do not configure AK/SK, you can still access public buckets using the BOS CLI.
- If and only if you use AK/SK provided by [Temporary Authorized Access](BOS/API Reference/Access control.md#Temporary authorized access) to access BOS, you need to provide a Security Token.
- Once the region is specified, you can omit the host, as BOS CLI will automatically append Region.bcebos.com as the host.
- If you specify a host, BOS CLI will directly use the specified host and will not append it automatically.
- You can enter none to set AK/SK/Region, and domain to null. When region is set to null, the default is bj; when domain is set to null, it will use the region to concatenate by default; if both are null, the default access address is bj.bcebos.com.
Note:
- If the AK/SK you are using is directly obtained from the Baidu AI Cloud Console’s security authentication, set the Security Token to null or none.
BOS-related configurations
In addition to general settings, the bce -c command also supports enabling automatic domain name switching and setting BOS upload-related attributes, such as the validity period of resumable upload, and whether to use the HTTPS protocol and the number of multi-threads for multipart uploads.
Set automatic domain name switching
BOS is available in multiple regions. When operating across different regions, the CLI’s automatic domain name switching feature enables seamless domain switching based on the region of the bucket you are accessing. This feature is enabled by default for convenience.
If you want all your operation requests to be sent to a specified domain name or Host (domain configured via bce -c), you can disable the "automatic domain name switching" function using the bce -c command. Set to no to disable this function.
1$ bce -c [<conf-path>]
2$ Default use auto switch domain [yes]:
Note: The value can be yes or no. Setting it to yes enables automatic domain name switching based on the bucket's region, while setting it to no disables it. This feature is enabled by default.
Set the validity period of resumable upload
The CLI supports resumable file uploads. If an upload is interrupted, you can re-execute the command to continue where it left off. This function requires you to configure a validity period. If interrupted within the validity period, the upload will resume from the breakpoint; if the period expires, a new upload will begin.
1$ bce -c [<conf-path>]
2$ Default breakpoint_file_expiration [7] days: Enter the period of keep breakpoint file
Note: The resumable upload validity period must be an integer of 0 or greater. Setting it to -1 ensures permanent retention. By default, the period is 7 days.
Set the HTTPS protocol for uploads
To ensure the security of user data, it is recommended to use the [HTTPS protocol for uploads](BOS/Typical Practices/HTTPS Transmission Encryption Practice.md). Whether to use HTTPS can be set via the bce -c command. Set it to no to use the HTTP protocol for uploads.
1$ bce -c [<conf-path>]
2$ Default use https protocol [no]:
Note: The value can be yes or no. By default, uploads use the HTTP protocol.
Set the number of parallel threads for multipart uploads
For multipart uploads of large files, you can set the number of parallel upload threads using the bce -c command.
1$ bce -c [<conf-path>]
2$ Default multi upload thread num [10]:
Note: The number of parallel upload threads must be set to an integer of 1 or greater. The default number is 10.
