Copied.
Downloading an Object
Scenarios
You can download objects from OBS to your local computer.
OBS supports batch download of objects. For details, see Does OBS Support Batch Download?
Constraints
- Objects in the Archive or Deep Archive storage class can be downloaded only when they are in the Restored state.
- Batch download is not supported on OBS Console. To batch download files or folders, you can use OBS Browser+ or obsutil.
Ways to Download an Object
You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to download an object.
Using OBS Console
- In the navigation pane of OBS Console, choose Object Storage.
- In the bucket list, click the bucket you want to operate. The Objects page is displayed.
- Download the object.
- To download a single object, do as follows:
Click Download in the Operation column of the object. The object is downloaded to the default path.
Alternatively, click More > Download As in the Operation column of the object. In the Download As dialog box, right-click the object name with the download link and choose Save link as... to download the object to a specified path.
- To download multiple objects in a batch, do as follows:
Select multiple objects and choose More > Download above the object list.
- To download a single object, do as follows:
Using APIs
Using the GUI Tool - OBS Browser+
- Log in to OBS Browser+.
- Go to the target bucket, select the file or folder you want to download, and click Download.
You can select multiple files or folders and batch download them.
- To download Archive files, you must restore them first. For details, see Restoring an Object.
- Only files or folders that have been listed can be downloaded in batches. You can drag the scroll bar to the bottom to update the number of listed files or folders. 100 files or folders can be updated at a time.
- In the displayed dialog box, select a path for saving the file or folder and click Select Folder.
Using the CLI Tool - obsutil
Command Line Structure
- In Windows
- Downloading a single object
obsutil cp obs://bucket/key file_or_folder_url [-tempFileDir=xxx] [-dryRun] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=52428800] [-versionId=xxx] [-ps=auto] [-cpd=xxx][-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Downloading objects in batches
obsutil cp obs://bucket[/key] folder_url -r [-tempFileDir=xxx] [-dryRun] [-f] [-flat] [-u] [-vlength] [-vmd5] [-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]
- Downloading a single object
- In Linux or macOS
- Downloading a single object
./obsutil cp obs://bucket/key file_or_folder_url [-tempFileDir=xxx] [-dryRun] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=52428800] [-versionId=xxx] [-ps=auto] [-cpd=xxx] [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Downloading objects in batches
./obsutil cp obs://bucket[/key] folder_url -r [-tempFileDir=xxx] [-dryRun] [-f] [-flat] [-u] [-vlength] [-vmd5] [-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]
- Downloading a single object
Examples
- Take the Windows OS as an example. Run the obsutil cp obs://bucket-test/key d:\temp\test.txt command to download a single object.
obsutil cp obs://bucket-test/key d:\temp\test.txt Start at 2024-09-30 08:39:34.180766 +0000 UTC Parallel: 5 Jobs: 5 Threshold: 50.00MB PartSize: auto VerifyLength: false VerifyMd5: false CheckpointDir: xxxx TempFileDir: xxxx [==========================================] 100.00% 4.86 KB/s 8.46MB/8.46MB 0s Download successfully, 8.46MB, obs://bucket-test/key --> d:\temp\test.txtt, cost [41], status [200], request id [000001924215BEC84019EDF4044A5451]
- Take the Windows OS as an example. Run the obsutil cp obs://bucket-test/temp d:\ -f -r command to download objects in batches.
obsutil cp obs://bucket-test/temp d:\ -f -r Start at 2024-09-30 08:41:56.0306522 +0000 UTC Parallel: 5 Jobs: 5 Threshold: 50.00MB PartSize: auto VerifyLength: false VerifyMd5: false CheckpointDir: xxxx Task id: 3066a4b0-4d21-4929-bb84-4829c32cbd0f OutputDir: xxxx TempFileDir: xxxx [======================================================] 100.00% tps:17.86 155.59 KB/s 7.20MB/7.20MB 0s Succeed count: 6 Failed count: 0 Succeed bytes: 70B Metrics [max cost:153 ms, min cost:129 ms, average cost:92.00 ms, average tps:70, transferred size: 7.20MB] Task id: 3066a4b0-4d21-4929-bb84-4829c32cbd0f
- For more examples, see Download.
Parameter Description
Parameter |
Optional or Mandatory |
Description |
---|---|---|
file_or_folder_url |
Mandatory for downloading an object |
The local file/folder path |
folder_url |
Mandatory for downloading objects in batches |
The local folder path |
bucket |
Mandatory |
The bucket name |
key |
Mandatory for downloading an object Optional for downloading objects in a batch |
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:
|
fr |
Optional for downloading an object (additional parameter) |
Generates an operation result file 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 batches. |
tempFileDir |
Optional (additional parameter) |
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. |
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.
CAUTION:
If your object needs encryption, do not use this parameter. |
p |
Optional (additional parameter) |
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:
|
versionId |
Optional for downloading an object (additional parameter) |
The source object version ID that can be specified when downloading an object |
ps |
Optional (additional parameter) |
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:
|
fs |
Optional (additional parameter) |
Whether the method of listing parallel file systems is applied. If you are listing parallel file systems, you are recommended to add this parameter.
CAUTION:
|
cpd |
Optional (additional parameter) |
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. |
r |
Mandatory for downloading objects in batches (additional parameter) |
Copies objects in batches based on a specified object name prefix. |
f |
Optional for downloading objects in batches (additional parameter) |
Runs in force mode. |
j |
Optional for downloading objects in batches (additional parameter) |
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 batches (additional parameter) |
The matching patterns of source objects that are excluded, for example, *.txt
NOTE:
NOTICE:
|
include |
Optional for downloading objects in batches (additional parameter) |
Specifies what formats of objects can be downloaded. If this parameter is set to *.jpg, only objects in the .jpg format can be downloaded.
NOTE:
NOTICE:
|
timeRange |
Optional for downloading objects in batches (additional parameter) |
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) |
The folder that stores the result files. After the command is executed, result files (possibly success, failure, and warning files) will be created in the specified folder. The default value is .obsutil_output, a subfolder in the user's home directory where obsutil commands are executed.
NOTE:
|
config |
Optional (additional parameter) |
The user-defined configuration file for executing the current command. To learn the parameters that can be configured in this file, see Configuration Parameters. |
e |
Optional (additional parameter) |
The endpoint |
i |
Optional (additional parameter) |
The user's AK |
k |
Optional (additional parameter) |
The user's SK |
t |
Optional (additional parameter) |
The user's security token |
Response
Field |
Description |
---|---|
Parallel |
The parameter -p in the request |
Jobs |
The parameter -j in the request |
Threshold |
The parameter -threshold in the request |
PartSize |
The parameter -ps in the request |
Exclude |
The parameter -exclude in the request |
Include |
The parameter -include in the request |
TimeRange |
The parameter -timeRange in the request |
VerifyLength |
The parameter -vlength in the request |
VerifyMd5 |
The parameter -vmd5 in the request |
CheckpointDir |
The parameter -cpd in the request |
OutputDir |
The parameter -o in the request |
ArcDir |
The parameter -arcDir in the request |
Succeed count |
The number of successful tasks |
Failed count |
The number of failed tasks |
Skip count |
The number of tasks that are skipped during incremental upload, download, or copy, and synchronous upload, download, or copy.
NOTE:
Skipped tasks are recorded into successful tasks. |
Warning count |
The number of tasks that are executed successfully but contain warnings.
NOTE:
|
Succeed bytes |
The number of bytes that are successfully uploaded or downloaded. |
max cost |
The maximum duration of all tasks, in ms |
min cost |
The minimum duration of all tasks, in ms |
average cost |
The average duration of all tasks, in ms |
average tps |
The average number of tasks completed per second |
Task id |
The unique ID of an operation, which is used to search for the result file generated for a batch task |
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