Files
doc-exports/docs/obs/tool-obsutil/obs_11_0051.html
weihongmin1 a41a4e0331 OBS Util 0115 Version
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
2026-02-17 10:18:57 +00:00

132 lines
18 KiB
HTML

<a name="obs_11_0051"></a><a name="obs_11_0051"></a>
<h1 class="topictitle1">Generating the Download Link of an Object</h1>
<div id="body1552529750621"><div class="section" id="obs_11_0051__section1479112110815"><h4 class="sectiontitle">Function</h4><p id="obs_11_0051__p11772825481">You can use this command to generate the download link of a specified object in a bucket or generate the download links of objects in a bucket in batches by object name prefix.</p>
</div>
<div class="section" id="obs_11_0051__section1220752192216"><h4 class="sectiontitle">Command Line Structure</h4><ul id="obs_11_0051__ul832417119303"><li id="obs_11_0051__li19324181113010">In Windows<ul id="obs_11_0051__ul14371109125314"><li id="obs_11_0051__li645116618536">Generating the download link of a single object<pre class="screen" id="obs_11_0051__screen2021764195319">obsutil sign obs://bucket/key [-e=300] [-config=xxx] </pre>
</li><li id="obs_11_0051__li18337131475317">Generating the download links of objects in batches by object name prefix<pre class="screen" id="obs_11_0051__screen15467124815533">obsutil sign obs://bucket[/key] -r [-e=300] [-timeRange=time1-time2] [-include=*.xxx] [-exclude=*.xxx] [-o=xxx] [-config=xxx] </pre>
</li></ul>
</li><li id="obs_11_0051__li1476086143015">In Linux or macOS<ul id="obs_11_0051__ul102477258222"><li id="obs_11_0051__li6786202119227">Generating the download link of a single object<pre class="screen" id="obs_11_0051__screen878692142210">./obsutil sign obs://bucket/key [-e=300] [-config=xxx] </pre>
</li><li id="obs_11_0051__li1978614214227">Generating the download links of objects in batches by object name prefix<pre class="screen" id="obs_11_0051__screen178620215229">./obsutil sign obs://bucket[/key] -r [-e=300] [-timeRange=time1-time2] [-include=*.xxx] [-exclude=*.xxx] [-o=xxx] [-config=xxx] </pre>
</li></ul>
</li></ul>
</div>
<div class="section" id="obs_11_0051__section2177102253816"><h4 class="sectiontitle">Examples</h4><ul id="obs_11_0051__ul617719223387"><li id="obs_11_0051__li1617716224381">In Windows, run <strong id="obs_11_0051__b129741610194715">obsutil sign obs://bucket-test/test.txt</strong> to generate a single object download link:<pre class="screen" id="obs_11_0051__screen20178122133815"><strong id="obs_11_0051__b1117811223385">obsutil <strong id="obs_11_0051__b91781622123813">sign </strong>obs://bucket-test/test.txt</strong>
Download url of [obs://bucket-test/test.txt] is:
http://your-endpoint/bucket-test/test.txt?AccessKeyId=xxxx&amp;Expires=1552548758&amp;Signature=xxxx</pre>
</li><li id="obs_11_0051__li1353310214414">In Windows, run <strong id="obs_11_0051__b55311539404">obsutil sign obs://bucket-test/test/ -r</strong> to generate object download links in batches:<pre class="screen" id="obs_11_0051__screen6531185313406"><strong id="obs_11_0051__b1953110532408">obsutil <strong id="obs_11_0051__b17531185324010">sign </strong>obs://bucket-test/test/ -r</strong>
Generate download urls for objects .
Generate the download url(s) for the objects in the bucket [<strong id="obs_11_0051__b554814236437">bucket-test</strong>] finished
Task id: af4dc692-6a88-4541-8156-ff1a889d2288</pre>
<div class="note" id="obs_11_0051__note1275751324515"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_11_0051__ul9354039174811"><li id="obs_11_0051__li1251908174914">If there are a large number of objects, obsutil saves the object download links to a specific file. The file name is associated with the task ID. For instance, the task ID in the example above is <strong id="obs_11_0051__b727631032415">af4dc692-6a88-4541-8156-ff1a889d2288</strong>, so the file name should be <strong id="obs_11_0051__b11566757132418">sign_succeed_report_{</strong><em id="obs_11_0051__i14246452152411">timestamp</em><strong id="obs_11_0051__b51671816253">}_af4dc692-6a88-4541-8156-ff1a889d2288.txt</strong>.</li><li id="obs_11_0051__li1335403917483">By default, the file is stored under folder <strong id="obs_11_0051__b0442125162512">.obsutil_output</strong> in your user directory. You can also use parameter <strong id="obs_11_0051__b126518449265">-o</strong> to specify a new folder.</li></ul>
</div></div>
</li></ul>
</div>
<div class="section" id="obs_11_0051__section6559191102418"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="obs_11_0051__table10831182114445" frame="border" border="1" rules="all"><thead align="left"><tr id="obs_11_0051__row683212154419"><th align="left" class="cellrowborder" valign="top" width="13%" id="mcps1.3.4.2.1.4.1.1"><p id="obs_11_0051__p118329219446">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18%" id="mcps1.3.4.2.1.4.1.2"><p id="obs_11_0051__p15137125919108">Optional or Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="69%" id="mcps1.3.4.2.1.4.1.3"><p id="obs_11_0051__p12832121184414">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_11_0051__row1096715662419"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p11357141182414">bucket</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p12357511172416">Mandatory</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p1435717116242">The bucket name</p>
</td>
</tr>
<tr id="obs_11_0051__row129424415242"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p11944643141811">key</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p19639114118186">Optional</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p16965474526">The object name used for generating the download link of a single object, or object name prefix used for generating download links of objects in batches</p>
</td>
</tr>
<tr id="obs_11_0051__row1320919474175"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p1720914714179">e</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p16209347141715">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p17209347151710">The validity period of the generated download links of objects, in seconds. Minimum value: 60s. Default value: 300s</p>
</td>
</tr>
<tr id="obs_11_0051__row1530918494177"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p15309164911712">r</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p7309749181710">Mandatory when generating download links of objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p15309114931714">Generates the download links of objects in batches by a specified object name prefix.</p>
</td>
</tr>
<tr id="obs_11_0051__row982613333425"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p156173113915">exclude</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p1930885652611">Optional when generating download links of objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p16666614131519">The matching patterns of objects that are excluded, for example: <strong id="obs_11_0051__b141934383516">*.txt</strong></p>
<div class="note" id="obs_11_0051__note145284716208"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="obs_11_0051__ul05604713204"><li id="obs_11_0051__li14580477208">The asterisk (*) represents any group of characters, and the question mark (?) represents any single character. For instance, <strong id="obs_11_0051__b960954194116">abc*.txt</strong> indicates any file whose name starts with <strong id="obs_11_0051__b196913548413">abc</strong> and ends with <strong id="obs_11_0051__b1070185411417">.txt</strong>.</li><li id="obs_11_0051__li10293181913349">You can use <strong id="obs_11_0051__b34091756134117">\*</strong> to represent <strong id="obs_11_0051__b19410165616411">*</strong> and <strong id="obs_11_0051__b154111456204116">\?</strong> to represent <strong id="obs_11_0051__b241265644119">?</strong>.</li><li id="obs_11_0051__li20603473203">If the name of the object to be downloaded matches the value of this parameter, the object is skipped.</li></ul>
</div></div>
<div class="notice" id="obs_11_0051__note179117549207"><span class="noticetitle"> NOTICE: </span><div class="noticebody"><ul id="obs_11_0051__ul877892116516"><li id="obs_11_0051__li1517310321518">You are advised to use quotation marks for the matching pattern to prevent special characters from being escaped by the OS and leading to unexpected results. Use single quotation marks for Linux or macOS and double quotation marks for Windows.</li><li id="obs_11_0051__li7566721111012">The matching pattern applies to the absolute path of an object, including the object name prefix and object name starting from the root directory. For example, if the path of an object in the bucket is <strong id="obs_11_0051__b639119353111">obs://bucket/src1/src2/test.txt</strong>, then the absolute path of the object is <strong id="obs_11_0051__b123921738315">src1/src2/test.txt</strong>.</li><li id="obs_11_0051__li10874112101017">This matching pattern applies only to objects whose names do not end with a slash (/).</li><li id="obs_11_0051__li1518953734020">Multiple <strong id="obs_11_0051__b12649043185412">exclude</strong> parameters can be specified, for example, <strong id="obs_11_0051__b6650174355411">-exclude=*.xxx -exclude=*.xxx</strong>.</li></ul>
</div></div>
</td>
</tr>
<tr id="obs_11_0051__row17153224213"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p186661845145315">include</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p966784516533">Optional when generating download links of objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p37071730153119">The matching patterns of objects that are included, for example: <strong id="obs_11_0051__b16049125112">*.jpg</strong></p>
<div class="note" id="obs_11_0051__note195168716220"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="obs_11_0051__ul752013715229"><li id="obs_11_0051__li135211772221">The asterisk (*) represents any group of characters, and the question mark (?) represents any single character.</li><li id="obs_11_0051__li151801324163419">You can use <strong id="obs_11_0051__b987530144318">\*</strong> to represent <strong id="obs_11_0051__b18877180184311">*</strong> and <strong id="obs_11_0051__b1287813084316">\?</strong> to represent <strong id="obs_11_0051__b287910134320">?</strong>.</li><li id="obs_11_0051__li201739642420">Only after identifying that the name of the file to be downloaded does not match the value of <strong id="obs_11_0051__b613133154313">exclude</strong>, the system checks whether the file name matches the value of this parameter. If yes, the file is downloaded. If not, the file is skipped.</li></ul>
</div></div>
<div class="notice" id="obs_11_0051__note9270217202212"><span class="noticetitle"> NOTICE: </span><div class="noticebody"><ul id="obs_11_0051__ul1329413124584"><li id="obs_11_0051__li14294512115812">You are advised to use quotation marks for the matching pattern to prevent special characters from being escaped by the OS and leading to unexpected results. Use single quotation marks for Linux or macOS and double quotation marks for Windows.</li><li id="obs_11_0051__li12968216131016">The matching pattern applies to the absolute path of an object, including the object name prefix and object name starting from the root directory. For example, if the path of an object in the bucket is <strong id="obs_11_0051__b81280613316">obs://bucket/src1/src2/test.txt</strong>, then the absolute path of the object is <strong id="obs_11_0051__b6129365319">src1/src2/test.txt</strong>.</li><li id="obs_11_0051__li1148165015513">This matching pattern applies only to objects whose names do not end with a slash (/).</li><li id="obs_11_0051__li1346454318403">Multiple <strong id="obs_11_0051__b01277461549">include</strong> parameters can be specified, for example, <strong id="obs_11_0051__b11279461544">-include=*.xxx -include=*.xxx</strong>.</li></ul>
</div></div>
</td>
</tr>
<tr id="obs_11_0051__row143423575435"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p496314014481">timeRange</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p1664510223494">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p16963940134813">The time range matching pattern when generating download links of objects. Only the download links of objects whose latest modification time is within the configured time range are generated.</p>
<p id="obs_11_0051__p2816559125317">This pattern has a lower priority than the object matching patterns (<strong id="obs_11_0051__b51820100612">exclude</strong>/<strong id="obs_11_0051__b132018108614">include</strong>). That is, the time range matching pattern is executed after the configured object matching patterns.</p>
<div class="note" id="obs_11_0051__note8766915165919"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="obs_11_0051__ul19272430145915"><li id="obs_11_0051__li17393154423217">Time in the matching pattern is the UTC time.</li><li id="obs_11_0051__li737595663220">This matching pattern applies only to objects whose names do not end with a slash (/).</li><li id="obs_11_0051__li12731730115918">The matching time range is represented in <em id="obs_11_0051__i12915187173118">time1</em><strong id="obs_11_0051__b169157716311">-</strong><em id="obs_11_0051__i189161733112">time2</em>, where <em id="obs_11_0051__i8917774312">time1</em> must be earlier than or the same as <em id="obs_11_0051__i11917375311">time2</em>. The time format is <em id="obs_11_0051__i5918579310">yyyyMMddHHmmss</em>.</li><li id="obs_11_0051__li32731530185916">Automatic formatting is supported. For example, yyyyMMdd is equivalent to yyyyMMdd000000, and yyyyMM is equivalent to yyyyMM01000000.</li><li id="obs_11_0051__li5185481610">If this parameter is set to <strong id="obs_11_0051__b179177993112">*-</strong><em id="obs_11_0051__i7918398313">time2</em>, all files whose latest modification time is earlier than <em id="obs_11_0051__i15918159123117">time2</em> are matched. If it is set to <em id="obs_11_0051__i109195963111">time1</em><strong id="obs_11_0051__b1391999143115">-*</strong>, all files whose latest modification time is later than <em id="obs_11_0051__i1792019173116">time1</em> are matched.</li></ul>
</div></div>
</td>
</tr>
<tr id="obs_11_0051__row0253155181712"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p102531251131712">o</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p92538516175">Optional when generating download links of objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p1632615718282">The folder that stores the result files. After the command is executed, result files (possibly success and failure files) will be created in the specified folder. The default value is <strong id="obs_11_0051__b18932936173211">.obsutil_output</strong>, a subfolder in the user's home directory where obsutil commands are executed.</p>
<div class="note" id="obs_11_0051__note1416817409247"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="obs_11_0051__ul101190347408"><li id="obs_11_0051__li111993418408">A result file should be named as follows: <strong id="obs_11_0051__b78111648155812">sign_{succeed | failed}_report_</strong><em id="obs_11_0051__i381234820584">time</em><strong id="obs_11_0051__b1981244865819">_TaskId.txt</strong>.<p id="obs_11_0051__li412103664016p0">By default, the maximum size of a single result file is 30 MB and the maximum number of result files that can be retained is 1,024. You can set the maximum size and number by configuring <strong id="obs_11_0051__b10360151153212">recordMaxLogSize</strong> and <strong id="obs_11_0051__b1436014515324">recordBackups</strong> in the configuration file.</p>
</li></ul>
</div></div>
</td>
</tr>
<tr id="obs_11_0051__row645016429369"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p153951131317">config</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p12395135316">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__obs_11_0008_p1750111452317">The user-defined configuration file for executing the current command. For details about parameters that can be configured, see <a href="obs_11_0035.html">Configuration Parameters</a>.</p>
</td>
</tr>
<tr id="obs_11_0051__row82031253113915"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.1.4.1.1 "><p id="obs_11_0051__p1966666191820">payer</p>
</td>
<td class="cellrowborder" valign="top" width="18%" headers="mcps1.3.4.2.1.4.1.2 "><p id="obs_11_0051__p1266611611820">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="69%" headers="mcps1.3.4.2.1.4.1.3 "><p id="obs_11_0051__p1166617619181">Specifies that requester pays is enabled.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0012.html">Object Commands</a></div>
</div>
</div>