百度智能云

All Product Document

          Object Storage

          Use of Bos Services by cmd

          The user can access to BOS service, manage and operate bucket and object by bos command. If the BOS service is insufficient in balance, Access Denied prompts up.

          CMD uses multi-layer command structure, and all commands start with bcecmd,[options] represents the options supported by BCE CMD; <service> indicates the services supported by CMD, such as BOS, etc., and each service has multiple specific sub-commands.

          $ bcecmd [options] [<service><command> [parameters [options]]] 

          Parameter Interpretation

          Parameter item Value Description
          options The value of BCE common Option is taken as-c,-v,-h,-d and--conf-path. -
          service The value taken can be bos and bosprobe. Please refer to bosprobe for the method to use bosprobe.
          command Value taken as: mb,rb,ls,cp,rm Please see the command function description for the role of each command.
          parameters The value is< local-path> or< bos-path>. < bos-path> includes the following forms:
          -BOS root directory: bos:/
          -BOS bucket root directory: Folder under bos:/< bucket-name>
          -BOS bucket: object under bos:/< bucket-name>/< folder-name>/
          -BOS bucket: bos:/< bucket-name>/< folder-name>/< object-key> Note If a bucket is followed by a number of "/" consecutively in < bos-path>, they are processed into one "/" The value of parameter
          can be a simple string or number, such as $ bcecmd bos cp localfile.txt bos:/mybucket/remotefile.txt. If the string contains spaces and special characters, use single quotation marks in Linux, and use double quotation marks in Windows. Such as $ bcecmd bos cp 'my object 1' 'bos:/mybucket/my object 1'
          +options The Option of command BOS is taken as-r,-aor-s, etc. The option configurable for all command of BOS is not the same. See each command line explanation for detailed method for use.

          Common Option of CMD

          • View Help You can add -h or --help to any command to view the help information for the command.

            $ bcecmd -h $ bcecmd bos -h $ bcecmd bos ls --help

          • View and set the configuration information of AK, SK, etc. -c/--configure

              $ bcecmd -c [<conf-path>] 
          • View the version information: -v/--version

              $ bcecmd -v 
          • View the debug information: -d/--debug

              $ bcecmd -d bos ls bos:/bce-test/pre/ 

            Note: The command -d/--debug cannot be used alone, and must be used in conjunction with the command bos.

          • Use specified configuration files: --conf-path

              $ bcecmd --conf-path ./conf-sample/ bos ls bos:/bce-test/pre/ 

            Note: When the command --conf-path is not used, the configuration under the home directory of user ~/.go-bcecli is used by default.

          Manage Bucket

          Create Bucket

          Description: Create an empty bucket.

          Command format: $ bcecmd bos mb bos:/<bucket-name> [--region REGION]

          Note:

          • You can specify a region for a bucket only after the function "Automatic Switching of Domain Name" is enabled.
          • If you do not specify the region to which the bucket belongs, we use the default region that you configured in CMD (that is, the default region configured with bcecmd -c, or the default region of CMD is bj if you do not configure the default region).

          Example

          • The region to which the bucket is created is not specified

            Example for operation:

            $ bcecmd bos mb bos:/mybucket

            Example for return:

            Make bucket: mybucket in region**

          • The region to which the bucket is created is specified

            Example for operation:

            $ bcecmd bos mb bos:/mybucket -r bj

            Example for return:

            Make bucket: mybucket in region bj

          Delete Bucket

          Description: Delete a bucket, requiring having no object in bucket or unfinished three-step uploading of Part.

          Command format: $ bcecmd bos rb bos:/<bucket-name> [-y, --yes] [-f, --force]

          Note:

          • -y, --yes: When using such option, skip the step of confirmation by default.
          • -f, --force: If you need to delete a non-empty bucket, you can use the option -f/--force to delete it forcibly. With this option, you can delete the bucket and all objects in it even if the bucket is not empty.

          Example for operation: $ bcecmd bos rb bos:/mybucket --force

          Example for return

          Do you really want to REMOVE bucket bos:/bce-test and all objects in it?(Y/N)**Y** 
          Delete object: bos:/mybucket/test1.txt 
          Delete object: bos:/mybucket/test2.txt 
          Remove bucket: mybucket 

          Enumerate Bucket

          Description: Enumerate bucket List.

          Command format: $ bcecmd bos ls [bos:/]

          Example for operation: $ bcecmd bos ls

          Example for return

          2015-08-12 10:20:58       bj  bce-doc 
          2015-08-12 10:21:09       bj  bce-sdk 
          2016-07-19 11:11:41       bj  bce-temp 
          2016-07-19 10:53:37       bj  bce-test 

          Note: The example outputs the first column that represents the creation date of bucket; the second column represents the creation time; the third column represents the region where the bucket is located; the fourth column represents the name of bucket.

          Manage Object

          Upload Object

          Description: BOS CMD supports three types of upload, including synchronous upload, single-file upload and batch upload, and the storage class of object can be specified during the upload, like standard storage or Infrequent Storage, Cold Storage or Archive Storage. In addition, BOS CMD also supports:

          • The file greater than 32M is split into multi-part automatically and uploaded in parallel, and set with concurrent connections of upload.

            When you need to upload the data between the local and BOS, sync is the most convenient upload command. Sync supports batch operation by default, and can synchronize the local directory to BOS. If there are files with the same name on BOS end and the modification time is newer than the local file, synchronized upload ignores this file and only synchronize the new or the changed files. The command sync enumerates the local and BOS-end files synchronously, and execute the following actions according to different situations:

          • For the new files (none at BOS end of a local file): Upload
          • For the uploaded but changed files (the local file is updated later than the creation time of the file at BOS end, or the size of local file is not consistent with that at BOS end): Upload by overriding
          • For the uploaded but not changed files: Skip them without processing
          • For the uploaded files that are not locally available: Process them differently according to the parameter --delete.

          Command Format

          • Sync upload: $ bcecmd bos sync<local_dir> bos:/<bucket_name>/[prefix] [--exclude EXCLUDE] [--include INCLUDE] [--delete] [--exclude-delete EXCLUDE-DELETE] [--dryrun] [--yes] [--quiet] [--storage-class STORAGE-CLASS] [--sync-type SYNC-TYPE] [--concurrency CONCURRENCY] [--restart]

            Parameter description

            • The local_dir must be a local directory, and cannot be a single file. Or, it also does not support the syntax matched with wildcard, such as <local_dir>/* or <local_dir>/prefix*, etc.
            • In Windows and Linux system,
            • as the ordinary files, and the soft-link folders are processed the same as the ordinary folders, but the soft-link files (refers to the soft link of the file) are not processed the same as the ordinary files; the sync operates the file to which the soft-link file refers instead of the soft link file itself, but the sync is triggered when the soft link itself is deleted.
            • --exclude: When the operations from local to bos are synchronized, the files to be skipped supports the wildcard * and multiple configurations, among which the wildcard * is parsed by shell and needs adding quotation mark.
            • To skip tem files and svn directories in all subdirectories of the current directory: --exclude './*.tmp' --exclude '*/.svn'
            • --include: When the operations from local to bos are synchronized, only the specified files are synchronized, with supports to the wildcard * and multiple configurations,
            • If only the log file and html file under all the sub-directories of current directory: --include './*.log' --include './*.html'
            • --delete: Delete the files that BOS has but not exist locally, so that the BOS and local data are exactly the same. The user is prompted to delete or not by default after execution.
            • --exclude-delete: Such option needs to be used in conjunction with --delete to exclude specific files or directories while deleting local files. Please refer to the rules of use for --exclude for specific method of use.
            • --dryrun: List the actions that are to be performed but are not performed actually.
            • --yes: Deletion is performed directly without confirmation.
            • --quiet: Upload synchronously but do not output any intermediate process.
            • --storage-class [STORAGE_CLASS]: Specify the storage class of object synchronized by storage-class parameter. When the storage-class is specified asSTANDARD_IA,COLDorARCHIVE, it indicates the storage is infrequent storage, cold storage or archival storage; when it is specified asSTANDARD or it is not specified, the storage is a standard storage.
            • --sync-type: The synchronization type can be time-size, time-size-crc32 and only-crc32, and it defaults to be time-size. When bcecmd executes sync, it judges whether the file to be synchronized exists at the destination end at first, if not, it uploads or downloads the file; if it exists in both source end and destination end, it determines whether to synchronize the file according to the synchronization type.
            • Type time-size: compare the modification date and size of the files at the source and destination end to determine whether the files are synchronized; when the modification date of the file at the source end is earlier than that of the destination end, the files are not synchronized; when the modification date of the files at the source end is equal to that of the destination end, and their sizes are the same, the files are not synchronized; otherwise, they are synchronized;
            • Type time-size-crc32: bcecmd uses time-size mode at first to determine whether to synchronize the files or not, when the output results of time-size indicates to synchronize the files, bcecmd compares crc32 of the files at the source and destination end, and only when the value of crc32 is different, the files are synchronized;
            • Type only-crc32: bcecmd only compares the crc32 of the files at the source and destination end, and it synchronizes the files as long as the value is different.
            • --concurrency: It is used to set the number of files uploaded and downloaded concurrently by the command sync.
            • --restart: It ignores the breakpoint resume and starts to upload the files again.

            Note:

            • When --delete and filtration (include or exclude) are used at the same time, if a file is filtered, despite it exists at the source and destination end at the same time, it is deleted. Just because bcecmd only compares the files that are not filtered.
            • Note that BOS does not fully support CRC32 until January 2018, so when bcecmd sync-type is selected as time-size-crc32 or only-crc32, if bcecmd fails to access the CRC32 information of the object, bcecmd will always synchronize these files.
          • Single-file upload: $ bcecmd bos cp<local-path><bos-path> [--storage-class [STORAGE_CLASS]] [--restart] [--quiet] [--yes] [--disable-bar]
          • Batch upload: $ bcecmd bos cp<local-path><bos-path> --recursive [--storage-class [STORAGE_CLASS]] [--restart] [--quiet] [--yes] [--disable-bar]

            Note:

            • When the command bcecm bos cp/tmp/file1 bos:/bucket/file2 is executed, file2 can be the same as file1, if file1 exists in the bucket, it is overridden.
            • When the command bcecmd bos cp/tmp/file bos:/bucket/is executed, it uses the local file name automatically as the file name at bos end, and the file with the same name that exists already is overridden.
            • When the command bcecmd bos cp/tmp/file bos:/bucket/prefix [/]-r is executed, if the local is a file, it is degraded to a single-file upload, and when bos path is ended with"/", prefix serves as a directory, and the new file is saved at the next level after prefix; if the it is not ended with "/", it is uploaded directly as an object name.
            • When the command bcecmd bos cp/tmp/dir/bos:/bucket/prefix [/]-r is executed, the local is a directory, no matter the bos path is ended with"/" or not, a new directory is created at bos end with the directory name of prefix; the object in the dir is copied to the prefix directory.
            • In terms of batch upload, the local-path can only be a local directory ending with "/", the bos-path must be bucket/prefix.
            • The storage-class parameter can be used to specify the storage type of object when the object is uploaded, and the storage-class is STANDARD by default, namely the standard storage, and when the storage-class is specified as STANDARD_IA, COLD or ARCHIVE, it indicates the storage is infrequent storage, cold storage or archival storage. If the input parameter of storage-class is wrong, it is still stored as STANDARD, with no error message prompted.
            • -disable-bar: The progress bar is not allowed for use.

          Example

          • Synchronize the sample directory under current directory to bos:/bce-test/test

            Example for operation: bcecmd bos sync ./sample/ bos:/bce-test/test

            Example for return:

               Upload: sample/BOS_Batch_Delete.png to bos:/bce-test/test/BOS_Batch_Delete.png 
               Upload: sample/sample.log to bos:/bce-test/test/sample.log 
          • List the synchronous operations that are to be performed but are not performed.

            Example for operation: bcecmd bos sync ./sample/ bos:/bce-test/test --dryrun

            Example for return:

               Upload: sample/BOS_DataImport.png to bos:/bce-test/test/BOS_DataImport.png 
          • Upload synchronously but do not output any intermediate process.

            Example for operation: bcecmd bos sync ./sample/ bos:/bce-test/test --quiet

            Example for return: No return

          • Synchronize the sample directory to bos:/bce-test/test and delete the files that BOS has but not locally

            Example for operation: bcecmd bos sync ./sample/ bos:/bce-test/test --delete

            Example for return:

               Delete object: bos:/bce-test/test/sample.log 
          • Synchronize the sample directory to bos:/bce-test/test and save as infrequent storage

            Example for operation: bcecmd bos sync ./sample/ bos:/bce-test/test --storage-class STANDARD_IA

            Example for return:

               Upload: sample/BOS_DataImport.png to bos:/bce-test/test/BOS_DataImport.png 
          • Synchronize the sample directory to bos:/bce-test/test and save as cold storage

            Example for operation: bcecmd bos sync ./sample/ bos:/bce-test/test --storage-class COLD

            Example for return:

               Upload: sample/BOS_DataImport.png to bos:/bce-test/test/BOS_DataImport.png 
          • Single-file upload

            Example for operation:

               $ bcecmd bos cp text.txt bos:/mybucket/test.txt 

            Example for return:

               Upload: test.txt to bos:/mybucket/test.txt 
          • Batch upload

            Example for operation:

               $ bcecmd bos cp ./temp/ bos:/bce-test -r 

            Example for return:

               Upload: /home/users/username/temp/BAE.png to bos:/bce-test/BAE.png 
               Upload: /home/users/username/tem/CreatePolicy.png to bos:/bce-test/CreatePolicy.png 
               Upload: /home/users/username/tem/BAE_Pro.png to bos:/bce-test/BAE_Pro.png 
               Upload: /home/users/username/tem/BCD.png to bos:/bce-test/BCD.png 
               Upload: /home/users/username/tem/04Eng.png to bos:/bce-test/04Eng.png 
               [5] object uploaded. 
          • Upload object and save as infrequent storage

            Example for operation:

               $ bcecmd bos cp text.txt bos:/mybucket/test.txt --storage-class STANDARD_IA 

            Example for return:

               Upload: test.txt to bos:/mybucket/test.txt 
          • Upload object and save as cold storage

            Example for operation:

               $ bcecmd bos cp text.txt bos:/mybucket/test.txt --storage-class COLD 

            Example for return:

               Upload: test.txt to bos:/mybucket/test.txt 

          Download Object

          Description: BOS CMD supports synchronized download, single-file download and batch download.

          The synchronized download supports batch operation by default, and synchronizes BOS to local directory. If there are files with the same name in local, and the modification time of the local file is later than the files with the same name on BOS, the synchronized upload ignores these files and only synchronizes the new or the changed files.

          The command sync enumerates the local and BOS-end files synchronously, and execute the following actions according to different situations:

          • For the new files (the local does not have a certain file of BOS): Download
          • For the downloaded but changed files (the BOS-end file is created later than the updating time of the local file, or the size of BOS-end file is not consistent with that at the local end): Download by overriding
          • For the downloaded but not changed files: Skip them without processing
          • For the file that has been downloaded but BOS end does not have: Process them differently according to the parameter --delete.

          Command Format

          • Synchronously download object: $ bcecmd bos sync<bos-dir><local-dir> [--exclude EXCLUDE][--include INCLUDE][--delete][--exclude-delete EXCLUDE-DELETE][--dryrun][--yes][--quiet][--sync-type SYNC-TYPE][--download-tmp-path DOWNLOAD-TMP-PATH][--concurrency CONCURRENCY][--restart]

            Note:

            • For synchronized download, local-dir and bos-dir must be directories, and cannot be a single file.
            • -exclude: When the local and bos are synchronized, the files to be skipped supports the wildcard * and multiple configurations.
            • To skip tem files under bucket sample and svn directories in all directories: --exclude 'bos:/sample/*.tmp' --exclude 'bos:/sample/*/.svn/*'
            • -include: When the operations from bos to the local are synchronized, only the specified files are synchronized, with supports to the wildcard * and multiple configurations,
            • If only the log file and html file under the bucket sample are synchronized: --include 'bos:/sample/*.log' --include 'bos:/sample/*.html'
            • -delete: Delete the files that the local has but BOS does not, so that the data of the local and BOS are completely the same. The user is prompted to delete or not by default after execution.
            • -exclude-delete: Such option needs to be used in conjunction with --delete to exclude specific files or directories at the destination end while deleting the files that exist in the destination end but not at the source end. Please refer to the rules of use for --exclude for specific method of use.
            • -dryrun: List the actions that are to be performed but are not performed actually.
            • -yes: Deletion is performed directly without confirmation.
            • -quiet: Download synchronously but do not output any intermediate process.
            • -sync-type: The synchronization type can be time-size, time-size-crc32 and only-crc32, and it defaults to be time-size. When bcecmd executes sync, it judges whether the file to be synchronized exists at the destination end at first, if not, it uploads or downloads the file; if it exists in both source end and destination end, it determines whether to synchronize the file according to the synchronization type.
            • Type time-size: compare the modification date and size of the files at the source and destination end to determine whether the files are synchronized; when the modification date of the file at the source end is earlier than that of the destination end, the files are not synchronized; when the modification date of the files at the source end is equal to that of the destination end, and their sizes are the same, the files are not synchronized; otherwise, they are synchronized;
            • Type time-size-crc32: bcecmd uses time-size mode at first to determine whether to synchronize the files or not, when the output results of time-size indicates to synchronize the files, bcecmd compares crc32 of the files at the source and destination end, and only when the value of crc32 is different, the files are synchronized;
            • Type only-crc32: bcecmd only compares the crc32 of the files at the source and destination end, and it synchronizes the files as long as the value is different.
            • -download-tmp-path: It is used to manually specify the directory to save temporary files during the breakpoint resume, if it is not specified; it defaults to use the directory where the command is executed.
            • -concurrency: It is used to set the number of files uploaded and downloaded concurrently by the command sync.
            • -restart: It ignores the breakpoint resume and starts to upload the files again.

            Note:

            • When --delete and filtration (include or exclude) are used at the same time, if a file is filtered, despite it exists at the source and destination end at the same time,
            • it is deleted. Just because bcecmd only compares the files that are not filtered.
            • Note that BOS does not fully support CRC32 until January 2018, so when bcecmd sync-type is selected as time-size-crc32 or only-crc32, if bcecmd fails to access the CRC32 information of the object, bcecmd will always synchronize these files.
          • Download a single object: $ bcecmd bos cp<bos-path><local-path> [--restart] [--storage-class STORAGE-CLASS] [--download-tmp-path DOWNLOAD-TMP-PATH] [--quiet] [--yes] [--disable-bar]
          • Download object in batch: $ bcecmd bos cp<bos-path><local-path> --recursive [--restart] [--storage-class STORAGE-CLASS] [--download-tmp-path DOWNLOAD-TMP-PATH] [--quiet] [--yes] [--disable-bar]

            Note:

            • When the command bcecmd bos cp bos:/bucket/file/tmp/file is executed, the local file name can be specified freely, and a prompt for overriding appears if a local file exists.
            • When the command bcecmd bos cp bos:/bucket/file/tmp/is executed, the local file name is saved as bos-end file name automatically, and a prompt for overriding appears in case of existence of the file.
            • When the command bcecmd bos cp bos:/bucket/file/tmp/-r is executed, the bos-end file is degraded to single-file download, and a prompt for overriding appears in case of existence.
            • When the command bcecmd bos cp bos:/bucket/prefix//tmp/-r is executed, if the local path reports an error for a file that has already existed, it is created if the local directory does not exist.
            • In terms of batch download, the local-path can only be a local directory, and the bos-path must be bucket/prefix. If the bos path is an object, it is a single object download.
            • --restart: It ignores the breakpoint resume and starts to download the files again.
            • --storage-class: During the download, no matter the parameter storage-class is specified or not, the download is not affected, such parameter will be ignored automatically, and does not work at all.
            • --download-tmp-path: It is used to manually specify the directory to save temporary files during the breakpoint resume, if it is not specified; it defaults to use the directory where the command is executed.
            • --quiet: Download synchronously but do not output any intermediate process.
            • --yes: Deletion is performed directly without confirmation.
            • --disable-bar: Do not display the progress bar.

          Example

          • Download the files under bos:/mybucket/pre/synchronously to the temp directory under the current directory

            Example for operation:

               $ bcecmd bos sync bos:/mybucket/pre/ ./temp/ 

            Example for return:

                 Download: bos:/mybucket/pre/sts1.png to /home/users/username/temp/sts1.png
                 Download: bos:/mybucket/pre/sts2.png to /home/users/username/temp/sts2.png
                 Sync done: bos:/mybucket/pre/ to ./temp/, [2] success [0] failure
          • Download object

            Example for operation:

               $ bcecmd bos cp bos:/mybucket/test.txt text.txt 

            Example for return:

               Download: bos:/mybucket/test.txt to test.txt 
          • Download object in batch

            Example for operation:

               $ bcecmd bos cp bos:/mybucket/pre/ temp -r 

            Example for return:

               Download: bos:/mybucket/pre/sts1.png to /home/users/username/tmp/sts1.png 
               Download: bos:/mybucket/pre/sts2.png to /home/users/username/tmp/sts2.png 
               [2] objects downloaded. 

          Copy Object

          Description: BOS CMD supports to copy files among buckets, supports synchronized copy, single-file copy and batch copy.

          The synchronized copy supports batch operations by default, and if there are files with the same name in bucket, the synchronized copy ignores these files and only synchronizes the new or the changed files.

          The command sync enumerates the source bucket and target bucket synchronously, and execute the following actions according to different situations:

          • For the new files (a certain file of source bucket while the target bucket does not have) Copy
          • For the copied but changed files (the file of source bucket is created later than the updating time of the target bucket file, or the size of file at the source bucket end is not consistent with that of target bucket): Copy by overriding
          • For the files that have been copied but not changed: Skip them without processing
          • For the files that have been copied but the source bucket does not have: Process them differently according to the parameter --delete.

          Command format

          • Synchronized copy of object: $ bcecmd bos sync<bos-dir><bos-dir> [--exclude EXCLUDE] [--include INCLUDE] [--delete] [--exclude-delete EXCLUDE-DELETE] [--dryrun] [--yes] [--quiet] [--storage-class STORAGE-CLASS] [--sync-type SYNC-TYPE] [--concurrency CONCURRENCY] [--restart]

            Note:

            • For synchronized copy, bos-dir must be a directory, and cannot be a single file.
            • --exclude: When the operations from bos and bos are synchronized, the files to be skipped supports the wildcard and multiple configurations. To skip the tmp files under bucket source and svn directory under all directories: `--exclude 'bos:/source/.tmp' --exclude 'bos:/source//.svn/'`
            • --include: When the operations from bos to bos are synchronized, only the specified files are synchronized, with supports to the wildcard and multiple configurations, If only the log file and html file under the bucket source are synchronized: `--include 'bos:/source/.log' --include 'bos:/source/*.html'`
            • --delete: Delete the files that the source bucket has but the target bucket does not have, so that the data of source and target bucket can be completely same. The user is prompted to delete or not by default after execution.
            • --exclude-delete: Such option needs to be used in conjunction with --delete to exclude specific files or directories at the destination end while deleting the files that exist in the destination end but not at the source end. Please refer to the rules of use for --exclude for specific method of use.
            • --dryrun: List the actions that are to be performed but are not performed actually.
            • --yes: Deletion is performed directly without confirmation.
            • --quiet: Upload synchronously but do not output any intermediate process.
            • --storage-class [STORAGE_CLASS]: Specify the storage class of object synchronized by storage-class parameter. When the storage-class is specified as STANDARD_IA, COLD or ARCHIVE, it indicates the storage is infrequent storage, cold storage or archival storage; when it is specified as STANDARD or it is not specified, the storage is a standard storage.
            • --sync-type: The synchronization type can be time-size, time-size-crc32 and only-crc32, and it defaults to be time-size. When bcecmd executes sync, it judges whether the file to be synchronized exists at the destination end at first, if not, it synchronizes the file; if it exists in both source end and destination end, it determines whether to synchronize the file according to the synchronization type.
            • --Type time-size: compare the modification date and size of the files at the source and destination end to determine whether the files are synchronized; when the modification date of the file at the source end is earlier than that of the destination end, the files are not synchronized; when the modification date of the files at the source end is equal to that of the destination end, and their sizes are the same, the files are not synchronized; otherwise, they are synchronized;
            • --Type time-size-crc32: bcecmd uses time-size mode at first to determine whether to synchronize the files or not, when the output results of time-size indicates to synchronize the files, bcecmd compares crc32 of the files at the source and destination end, and only when the value of crc32 is different, the files are synchronized;
            • --Type only-crc32: bcecmd only compares the crc32 of the files at the source and destination end, and it synchronizes the files as long as the value is different.
            • --concurrency: It is used to set the number of files copied concurrently by the command sync.
            • --restart: It ignores the breakpoint resume and starts to copy the files again.

            Note:

            • When --delete and filtration (include or exclude) are used at the same time, if a file is filtered, it is deleted despite it exists at the source and destination end at the same time, Just because bcecmd only compares the files that are not filtered.
            • Note that BOS does not fully support CRC32 until January 2018, so when bcecmd sync-type is selected as time-size-crc32 or only-crc32, if bcecmd fails to access the CRC32 information of the object, bcecmd will always synchronize these files.
          • Copy a single object: $ bcecmd bos cp<bos-path><bos-path> [--restart] [--storage-class STORAGE-CLASS] [--quiet] [--yes] [--disable-bar]
          • Batch copy of object: $ bcecmd bos cp<bos-path><bos-path> --recursive [--restart] [--storage-class STORAGE-CLASS] [--quiet] [--yes] [--disable-bar]

            Note:

            • When the command bcecmd bos cp bos:/bucket/obj1 bos:/bucket/obj2 is executed, an error is reported if the two paths copied are the same, and the target path is overridden if it exists.
            • When the command bcecmd bos cp bos:/bucket/obj1 bos:/bucket/prefix/is executing, obj1 is copied under prefix directory, and the target path must be ended with "/"; otherwise a new file is created with a new file name.
            • When command bcecmd bos cp bos:/bucket/obj1 bos:/bucket/prefix/-r is executed, it is degraded into single-file copy when the source path is a single file, and obj1 is copied under the directory of prefix.
            • When the command bcecmd bos cp bos:/bucket/prefix1/bos:/bucket/prefix2/-r is executed, the copy from directory to directory is realized, and both paths must be ended with "/"; if the target path is not ended with "/", an error is reported as a single file.
            • In terms of batch copy executed, the bos-path must be bucket/prefix.
            • The user must have the read permission for the source bucket and write permission for the target bucket.

          Example

          • Copy the files under bos:/mybucket/pre/synchronously to bos:/mybucket2/pre/

            Example for operation:

               $ bcecmd bos sync bos:/mybucket/pre/ bos:/mybucket2/pre/ 

            Example for return:

               Copy: bos:/mybucket/pre/sts1.png to bos:/mybucket2/pre/sts1.png 
               Copy: bos:/mybucket/pre/sts2.png to bos:/mybucket2/pre/sts2.png 
               Sync done: bos:/mybucket/pre/ to bos:/mybucket2/pre/, [2] success [0] failure 
          • Copy a single object

            Example for operation:

               $ bcecmd bos cp bos:/mybucket/test.txt bos:/mybucket2/test.txt 

            Example for return:

               Copy: bos:/mybucket/test.txt to bos:/mybucket2/test.txt 
          • Batch copy of object

            Example for operation:

               $ bcecmd bos cp bos:/mybucket/pre1/ bos:/bce-test/pre/ -r 

            Example for return:

               Copy: bos:/mybucket/pre1/s1.png to bos:/bce-test/pre/s1.png 
               Copy: bos:/mybucket/pre1/s2.png to bos:/bce-test/pre/s2.png 
               [2] objects remote copied. 

          Enumerate Object

          Description: The command ls can enumerate no more than 1000 objects in a bucket, and can filter the results by specifying Prefix. The command ls uses/as delimiter automatically to simulate the folder.

          Command format $ bcecmd bos ls bos:/<bucket-name>/[prefix]

          Example for operation bcecmd bos ls bos:/mybucket/web

          Example for return

                                                       PRE  pre/
          2016-04-01 16:43:01            8698     STANDARD  web_bos.png
          2016-04-01 16:41:49           17188     STANDARD  web_server_bos.png
          2016-04-01 16:43:53           24620  STANDARD_IA  webtobos_cors.png
          2016-04-01 16:45:53           24623         COLD  cold_abc.png

          Note:

          • -a, --all: All are displayed in case of more than 1000 objects.
          • -r, --recursive: Instead of displaying the directory, the object below is displayed directly.
          • -s, --summerize: Display number and total size and other statistical information.
          • The example outputs the first column that represents the creation date of object; the second column represents the creation time; the third column represents the size of object (with Byte as unit); the fourth column represents the storage class of object; the fifth column represents the name of bucket.
          • The pre/represents the folder, and does not display the creation time and size information.

          Get the URL of Object

          Description: The command gen_signed_url can access the URL of specified object, and download object according to the URL provided.

          Command format $ bcecmd bos gen_signed_url bos:/<bucket-name>/<object-key> [-eTIME]

          Note:

          • The object can be downloaded directly by inputting the URL accessed into the browser. Prior to the generation of URL, it is required to confirm whether AK/SK configured is consistent with AK/SK of corresponding account of bucket; otherwise, the ULR generated is invalid and cannot download object normally.
          • -e: Specify the expiration time of URL (unit: second), the value must be greater than or equal to -1; whereas -1 indicates that URL is valid permanently.
          • If the expiration time is not specified, the expiration time is 1800 seconds by default.

          Note: No spacing is allowed between parameter -e and the expiration time.

          Example

          • Expiration time that is not specified

            Example for operation:

               $ bcecmd bos gen_signed_url bos:/bce-test/test/BOS_DataImport.png 

            Example for return:

               http://bj.bcebos.com/bce-test/test/BOS_DataImport.png?authorization=bce-auth-v1%2Fd35a0b8750114e49b3567e0b0542c2f1%2F2016-08-25T02%3A03%3A57Z%2F1800%2F%2F96d77180ec2cb7e8de522c15ca42bf67c30bae0edb47bad495fe8e7953794a4f 
          • The expiration time specified is 100 seconds.

            Example for operation:

               $ bcecmd bos gen_signed_url bos:/bce-test/test/BOS_DataImport.png -e100 

            Example for return:

               http://bj.bcebos.com/bce-test/test/BOS_DataImport.png?authorization=bce-auth-v1%2F637986f41b0046248e3a333817371502%2F2017-08-31T03%3A19%3A42Z%2F100%2F%2F3e77accca7f0206460c662b0a9596b7ec353599214d42b124bb797a48da7359a 
          • The URL specified is valid permanently.

            Example for operation:

               $ bcecmd bos gen_signed_url bos:/bce-test/test/BOS_DataImport.png -e-1 

            Example for return:

               http://bj.bcebos.com/bce-test/test/BOS_DataImport.png?authorization=bce-auth-v1%2F637986f41b0046248e3a333817371502%2F2017-08-31T03%3A19%3A42Z%2F-12F%2F3e77accca7f0206460c662b0a9596b7ec353599214d42b124bb797a48da7359a 

          Delete Object

          Command format

          • Delete a single object: $ bcecmd bos rm [-y, --yes] bos:/<bucket-name>/<object-key>
          • Delete object in batch: $ bcecmd bos rm [-y, --yes] [-r, --recursive] bos:/<bucket-name>/<prefix>

          Note:

          • -y, --yes: When using such option, skip the step of confirmation.
          • -r, --recursive: Delete objects in batches.

          Example

          • Delete a single object

            Example for operation:

               $ bcecmd bos rm bos:/bce-temp/s1.png 

            Example for return:

                 Do you really want to REMOVE object bos:/bce-temp/s1.png? (Y/N) **Y**
                 Delete object: bos:/bce-temp/s1.png
          • Delete object in batch

            Example for operation:

                 $ bcecmd bos rm bos:/bce-test/pre/ -r

            Example for return:

                 Delete object: bos:/bce-test/pre/s1.png
                 Delete object: bos:/bce-test/pre/s2.png
                 [2] objects removed on remote.

          Access the Meta-data of Object

          Description: The command get-object-meta is used to access the meta information of specific object in the specified bucket.

          Command format

          • $ bcecmd bosapi get-object-meta --bucket-name BUCKET-NAME --object-name OBJECT-NAME

          Note:

          • -bucket-name: bucket name
          • -object-name: object name to be inquired

          Example

          Example for operation:

          $ bcecmd bosapi get-object-meta --bucket-name=100kperf-xitaotao --object-name=water

          Example for return: 2019 / 10 / 10 11: 06: 49 { "CacheControl": "", "ContentDisposition": "", "ContentEncoding": "", "ContentLength": 0, "ContentRange": "", "ContentType": "application/json", "ContentMD5": "1B2M2Y8AsgTpgAmY7PhCfg==", "ContentSha256": "", "Expires": "Sun, 13 Oct 2019 03:06:49 GMT", "LastModified": "Thu, 26 Sep 2019 08:55:32 GMT", "ETag": "d41d8cd98f00b204e9800998ecf8427e", "UserMeta": null, "StorageClass": "COLD", "NextAppendOffset": "", "ObjectType": "", "Crc32": "0" }

          BOSAIP Interface Management

          BOSAPI interface management includes the bucket ACL, default storage class of bucket, lifecycle management and log management. The common format of command line is bcecmd bosapi [--help].

          Set Bucket ACL

          Description: There are two methods to configure bucket ACL: 1.Use CannedAcl; 2.Set bucket ACL by uploading ACL Configuration File.

          Command format

          bcecmd bosapi put-bucket-acl --bucket-name BUCKET-NAME [--acl-config-file ACL-CONFIG-FILE][--canned CANNED] 

          Note:

          • Use --acl-config-fileto specify ACL configuration file, and please refer to Bucket Access Control;
          • Use --canned to set CannedACL, and the CannedACL supported currently include private, public-read, and public-read-write;
          • --acl-config-file and --canned cannot be used at the same time;
          • When CannedACL is configured, an error message is printed if the configuration fails; otherwise, no message is output if the configuration succeeds;
          • When bucket ACL is set while uploading ACL configuration file, ACL configuration information is printed if the configuration succeeds; the contents of ACL configuration file and error message are printed in case of failure.

          Example

          • Permission control using CannedAcl

            Example for operation:

            $ bcecmd bosapi put-bucket-acl --bucket-name bucket1 --canned private 

            Example for return: None

          • Set bucket ACL by uploading ACL configuration files

            Example for operation:

            $ bcecmd bosapi put-bucket-acl --bucket-name bucket1 --acl-config-file acl-config.json 

            Example for return:

             { 
                  "accessControlList": [ 
                    { 
                      "grantee": [ 
                        { 
                          "id": "e13b12d213213213232323f492323" 
                        } 
                      ], 
                      "permission": [ 
                          "READ" 
                      ] 
                    } 
                  ] 
              } 

          Access Bucket ACL

          Description: Access the configuration of bucket ACL

          Command format

          bcecmd bosapi get-bucket-acl --bucket-name BUCKET-NAME 

          Example for operation

          bcecmd bosapi get-bucet-acl --bucket-name bucket1 

          Example for return

          { 
            "accessControlList": [ 
              { 
                "grantee": [ 
                  { 
                    "id": "e13b12d213213213232323f492323" 
                  } 
                ], 
                "permission": [ 
                  "FULL_CONTROL"
                ], 
                "condition": { 
                  "ipAddress": null, 
                  "referer": { 
                    "stringLike": null, 
                    "stringEquals": null 
                  } 
                } 
              } 
            ], 
            "owner": { 
              "id": "e13b12d213213213232323f492323" 
            } 
          } 

          Set the Lifecycle

          Description: Set the Lifecycle Management Rules, or generate the lifecycle management file template for the specified bucket according to the lifecycle management file provided.

          Command format

          • Generate the configuration template of Transition: bcecmd bosapi put-lifecycle --template
          • Set the lifecycle management rule for the bucket according to the specified configuration file. bcecmd bosapi put-lifecycle --lifecycle-config-file LIFECYCLE_CONFIG_FILE --bucket-name BUCKET_NAME

          Example

          • Generate the configuration template of Transition

            Example for operation:

             $ bcecmd bosapi put-lifecycle --template 

            Example for return:

             { 
                "rule": [ 
                  { 
                    "action": { 
                      "name": "Transition", 
                      "storageClass": "STANDARD_IA" 
                    }, 
                    "status": "enabled", 
                    "resource": [ 
                      "${bucket_name}/${prefix}/*" 
                    ], 
                    "id": "sample-id", 
                    "condition": { 
                      "time:": { 
                        "dateGreaterThan": "$(lastModified)+P30D" 
                      } 
                    } 
                  } 
                ] 
              } 
          • Set the lifecycle management rule for the bucket1 according to the configuration file 1.txt

            Example for operation:

            bcecmd bosapi put-lifecycle --lifecycle-config-file lifecycle_bj.json --bucket-name bucket1

            Example for return:

            {
              "rule": [
                {
                  "status": "enabled",
                  "action": {
                    "name": "Transition",
                    "storageClass": "STANDARD_IA"
                  },
                  "resource": [
                    "bucket1/*"
                  ],
                  "id": "sample-rule-transition",
                  "condition": {
                    "time": {
                      "dateGreaterThan": "$(lastModified)+P180D"
                    }
                  }
              }
              ]
            }

            Note: Return to the lifecycle configuration file if it is set successfully, or report an error.

          Access the Configurations of Lifecycle

          Description: Access the configuration of the lifecycle of a certain bucket specified.

          Command format: bcecmd bosapi get-lifecycle --bucket-name BUCKET_NAME

          Example for operation: bcecmd bosapi get-lifecycle --bucket-name bucket1

          Example for return

          {
            "rule": [
              {
                "action": {
                  "name": "Transition",
                  "storageClass": "STANDARD_IA"
                },
                "status": "enabled",
                "resource": [
                  "bucket1/prefix1/*"
                ],
                "id": "sample-id",
                "condition": {
                  "time:": {
                    "dateGreaterThan": "$(lastModified)+P30D"
                  }
                }
              }
            ]
          }

          Delete the Configurations of Lifecycle

          Description: Delete the configuration of the lifecycle of a specified bucket.

          Command format: bcecmd bosapi delete-lifecycle --bucket-name BUCKET_NAME

          Example for operation: bcecmd bosapi delete-lifecycle --bucket-name bucket1

          Example for return: None

          Set the Log Rule

          Description: Enable Log Access Function for bucket, and save under prefix of specified bucket.

          Command format: bcecmd bosapi put-logging --target-bucket TARGET_BUCKET --target-prefix TARGET_PREFIX --bucket-name BUCKET_NAME

          Example for operation: bcecmd bosapi put-logging --target-bucket bucket2 --target-prefix log --bucket-name bucket1

          Example for return None

          Access the Log Rule

          Description: Access the log access configuration of specified bucket.

          Command format: bcecmd bosapi get-logging --bucket-name BUCKET_NAME

          Example for operation: bcecmd bosapi get-logging --bucket-name bucket1

          Example for return

          $ bcecmd bosapi get-logging --bucket-name bucket1
          {
            "status": "enabled",
            "targetPrefix": "loggin/",
            "targetBucket": "bucket1"
          }

          Delete the Log Rule

          Description: Delete the log access setting of specified bucket.

          Command format: bcecmd bosapi delete-logging --bucket-name BUCKET_NAME

          Example for operation: bcecmd bosapi delete-logging --bucket-name b1

          Example for return: None

          Set the Default Storage Class of Bucket

          Description: Set the default storage class of a certain specified bucket;

          If object uploaded by users with API, CLI, or SDK does not specify a storage type, the default storage type of bucket will be inherited. If storage type specified by uploaded object is different from default storage type of bucket, storage type of object shall prevail. The storage class includes four types: (STANDARD) (standard storage), (STANDARD_IA) (infrequent storage), (COLD) (cold storage) and (ARCHIVE) (archival storage). Please refer to the Hierarchical Storage for specific application scenario and performance; please refer to the Create Bucket for setting the default storage class of bucket via Console.

          Command format

          bcecmd bosapi put-bucket-storage-class --bucket-name BUCKET_NAME --storage-class STORAGE_CLASS 

          Example for operation

          bcecmd bosapi put-bucket-storage-class --bucket-name bucket1 --storage-class COLD` 

          Example for return: No return

          Query the Default Storage Class of Bucket

          Description: The command is used to query the default storage class of a certain bucket, and the default storage class of bucket includes standard storage, infrequent storage and cold storage and archival storage.

          Command format

          bcecmd bosapi get-bucket-storage-class --bucket-name BUCKET_NAME 

          Example for operation

          bcecmd bosapi get-bucket-storage-class --bucket-name bucket1 

          Example for return

          { 
              "storageClass":"COLD" 
          }
          Previous
          Configure BOSCMD
          Next
          BOSCMD Version Change Record