Downloading Objects by Using an Authorization Code
Function
You can use this command to download an object or download objects in a batch by object name prefix to your local PC.
Do not change the source objects in the OBS bucket when downloading a single object or objects in batches. Otherwise, the download may fail or data may be inconsistent.
Command Line Structure
- In Windows
- Enter the authorization code to download a single object.
obsutil share-cp authorization_code file_or_folder_url -key=xxx [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=52428800] [-ps=auto] [-cpd=xxx][-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Use the file path to transfer the authorization code and download a single object.
obsutil share-cp file://authorization_code_file_url file_or_folder_url -key=xxx [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=52428800] [-ps=auto] [-cpd=xxx][-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Enter the authorization code to download objects in a batch.
obsutil share-cp authorization_code folder_url -r [-key=xxx] [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-f] [-u] [-vlength] [-vmd5] [-flat] [-j=1] [-p=1] [-threshold=52428800] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Use the file path to transfer the authorization code and download objects in a batch.
obsutil share-cp file://authorization_code_file_url folder_url -r [-key=xxx] [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-f] [-u] [-vlength] [-vmd5] [-flat] [-j=1] [-p=1] [-threshold=52428800] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Enter the authorization code to download a single object.
- In Linux or macOS
- Enter the authorization code to download a single object.
./obsutil share-cp authorization_code file_or_folder_url -key=xxx [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=52428800] [-ps=auto] [-cpd=xxx][-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Use the file path to transfer the authorization code and download a single object.
./obsutil share-cp file://authorization_code_file_url file_or_folder_url -key=xxx [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=52428800] [-ps=auto] [-cpd=xxx][-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Enter the authorization code to download objects in a batch.
./obsutil share-cp authorization_code folder_url -r [-key=xxx] [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-f] [-u] [-vlength] [-vmd5] [-flat] [-j=1] [-p=1] [-threshold=52428800] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Use the file path to transfer the authorization code and download objects in a batch.
./obsutil share-cp file://authorization_code_file_url folder_url -r [-key=xxx] [-ac=xxx] [-dryRun] [-tempFileDir=xxx] [-f] [-u] [-vlength] [-vmd5] [-flat] [-j=1] [-p=1] [-threshold=52428800] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Enter the authorization code to download a single object.
Examples
- In Windows, you can run the obsutil share-cp xxx d:\temp\test.txt -ac=123456 -key=src/test.txt command to download a single object.
obsutil share-cp xxx d:\temp\test.txt -ac=123456 -key=test/test.txt Parallel: 3 Jobs: 3 Threshold: 524288000 PartSize: auto VerifyLength: false VerifyMd5: false CheckpointDir: xxxx TempFileDir: xxxx [==========================================] 100.00% 4.86 KB/s 0s Download successfully, 19B, n/a, https://endpoint:443/test/test.txt --> d:\temp\test.txt The authorized prefix is [test/]
- In Windows, you can run the obsutil share-cp xxx d:\temp -ac=123456 -f -r command to download objects in a batch.
obsutil share-cp xxx d:\temp -ac=123456 -f -r Parallel: 3 Jobs: 3 Threshold: 524288000 PartSize: 5242880 VerifyLength: false VerifyMd5: false CheckpointDir: xxxx OutputDir: xxxx TempFileDir: xxxx [======================================================] 100.00% 155.59 KB/s 0s Succeed count is: 6 Failed count is: 0 Metrics [max cost:153 ms, min cost:129 ms, average cost:92.00 ms, average tps:17.86] Task id: 1a50b1dd-3f92-42ae-a974-ff8fe514c2c2 The authorized prefix is [test/]
Parameter Description
Parameter |
Optional or Mandatory |
Description |
---|---|---|
authorization_code or file://authorization_code_file_url |
Mandatory |
Code for authorization
NOTE:
If the authorization code starts with file://, the authorization code is obtained from a local file. |
file_or_folder_url |
Mandatory for downloading an object |
Local file/folder path |
folder_url |
Mandatory for downloading objects in a batch |
Local folder path |
key |
Mandatory for downloading an object (additional parameter) Optional for downloading objects in a batch |
Indicates the name of the object to be downloaded, or the name prefix of the objects to be downloaded in batches. This parameter cannot be left blank when downloading an object. The saving and naming rules are as follows:
During batch download, the saving rules are as follows:
NOTE:
NOTICE:
During batch download, if the flat option is selected and the object name prefix is empty or does not end with a slash (/) during authorization code creation, the downloaded object list may be empty. |
ac |
Optional (additional parameter) |
Access code
NOTE:
|
r |
Mandatory for downloading objects in batches (additional parameter) |
Copies objects in batches based on a specified object name prefix. |
fr |
Optional for downloading an object (additional parameter) |
Generates an operation result list when downloading an object. |
flat |
Optional for downloading objects in batches (additional parameter) |
The name prefix of the parent object is excluded when downloading objects in a batch. |
tempFileDir |
Optional (additional parameter) |
Indicates the directory for storing temporary files during multipart download. The default value is the value of defaultTempFileDir in the configuration file.
NOTE:
|
dryRun |
Optional (additional parameter) |
Conducts a dry run. |
u |
Optional (additional parameter) |
Indicates incremental download. If this parameter is set, each object can be downloaded only when it does not exist in the local path, its size is different from the namesake one in the local path, or it has the latest modification time.
CAUTION:
When you compare each local file with data in the bucket, a billable HEAD request is generated. For details, see Requests. |
vlength |
Optional (additional parameter) |
Checks whether the sizes of the local files are the same as those of the objects in the bucket after the download is complete. |
vmd5 |
Optional (additional parameter) |
Checks whether MD5 values of the local files are the same as those of the objects in the bucket after the download is complete.
NOTE:
Objects in the bucket must contain metadata x-obs-meta-md5chksum, or MD5 verification will be skipped. |
p |
Optional (additional parameter) |
Indicates the maximum number of concurrent multipart download tasks when downloading an object. The default value is the value of defaultParallels in the configuration file. |
threshold |
Optional (additional parameter) |
Indicates the threshold for enabling multipart download, in bytes. The default value is the value of defaultBigfileThreshold in the configuration file.
NOTE:
|
ps |
Optional (additional parameter) |
Indicates the size of each part in a multipart download task, in bytes. The default value is the value of defaultPartSize in the configuration file.
NOTE:
|
cpd |
Optional (additional parameter) |
Indicates the folder where the part records reside. The default value is .obsutil_checkpoint, the subfolder in the home directory of the user who executes obsutil commands.
NOTE:
A part record is generated during a multipart download and saved to the down subfolder. After the download succeeds, its part record is deleted automatically. If the download fails or is suspended, the system attempts to resume the task according to its part record when you perform the download the next time. |
f |
Optional for downloading objects in a batch (additional parameter) |
Runs in force mode. |
j |
Optional for downloading objects in a batch (additional parameter) |
Indicates the maximum number of concurrent tasks for downloading objects in a batch. The default value is the value of defaultJobs in the configuration file.
NOTE:
The value is ensured to be greater than or equal to 1. |
exclude |
Optional for downloading objects in a batch (additional parameter) |
Indicates the matching patterns of source objects that are excluded, for example: *.txt.
NOTE:
NOTICE:
|
include |
Optional for downloading objects in a batch (additional parameter) |
Indicates the matching patterns of source objects that are included, for example: *.jpg.
NOTE:
NOTICE:
|
timeRange |
Optional for downloading objects in a batch (additional parameter) |
Indicates the time range matching pattern when downloading objects. Only objects whose latest modification time is within the configured time range are downloaded. This pattern has a lower priority than the object matching patterns (exclude/include). That is, the time range matching pattern is executed after the configured object matching patterns.
NOTE:
NOTICE:
|
mf |
Optional (additional parameter) |
Indicates that the name matching pattern (include or exclude) and the time matching pattern (timeRange) also take effect on objects whose names end with a slash (/). |
o |
Optional (additional parameter) |
Indicates the folder where operation result lists reside. After the command is executed, result lists (possibly including success, failure, and warning files) are generated in the folder. The default value is .obsutil_output, the subfolder in the home directory of the user who executes obsutil commands.
NOTE:
|
config |
Optional (additional parameter) |
User-defined configuration file for executing a command. For details about parameters that can be configured, see Configuration Parameters. |
e |
Optional (additional parameter) |
Specifies the endpoint. |
i |
Optional (additional parameter) |
Specifies the user's AK. |
k |
Optional (additional parameter) |
Specifies the user's SK. |
t |
Optional (additional parameter) |
Specifies the user's security token. |
Response
Refer to Response for uploading an object.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot