Files
doc-exports/docs/obs/tool-obsutil/obs_11_0069.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

25 lines
5.3 KiB
HTML

<a name="obs_11_0069"></a><a name="obs_11_0069"></a>
<h1 class="topictitle1">Using obsutil to Share Directories</h1>
<div id="body1568873184664"><p id="obs_11_0069__p1319922315525">The directory sharing function allows the owner of a bucket to share directories in a bucket or the entire bucket with other users by using the authorization code and access code. If you have the valid authorization code and access code of a shared folder, you can use OBS tools (OBS Browser and obsutil) to access the folder, list objects, and download objects. Alternatively, you can directly enter the authorization code in the address box of a web browser to list and download objects.</p>
<p id="obs_11_0069__p8060118">obsutil provides three commands to implement directory sharing. The procedure is as follows:</p>
<ol id="obs_11_0069__ol33181141111"><li id="obs_11_0069__li10318191419111"><span>Run the <strong id="obs_11_0069__b565019812428">obsutil create-share</strong> command to create an authorization code for sharing a directory. For example, you can run the following command to share the <strong id="obs_11_0069__b1332420486420">test</strong> directory in the bucket named <strong id="obs_11_0069__b1887720915435">bucket</strong> with the access code set to <strong id="obs_11_0069__b821834620437">123456</strong> and the validity period set to <strong id="obs_11_0069__b18540205414432">10</strong> days:</span><p><pre class="screen" id="obs_11_0069__screen142052039192217">obsutil create-share obs://bucket/test/ -ac=123456 -vp=10d</pre>
<div class="note" id="obs_11_0069__note8986162612248"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_11_0069__ul66594410248"><li id="obs_11_0069__li165913418243">When creating an authorization code, you are advised to end the name of the directory to be shared always with a slash (/). If no directory name is specified in the command (for example, only <strong id="obs_11_0069__b197901781879">obs://bucket</strong> is specified in the command), the entire bucket is shared.</li><li id="obs_11_0069__li206439288237">If you do not use the <strong id="obs_11_0069__b18699179450">ac</strong> option to set the access code, obsutil will prompt you to enter the access code. The access code must be a six-digit string.</li><li id="obs_11_0069__li3363225132614">For details about this command, see <a href="obs_11_0062.html">Creating an Authorization Code for Directory Sharing</a>.</li></ul>
</div></div>
</p></li><li id="obs_11_0069__li169260277222"><span>Run the <strong id="obs_11_0069__b1001139469">obsutil share-ls</strong> command to list objects in the bucket. For example, to list the first 100 objects in the <strong id="obs_11_0069__b8909538134613">test</strong> directory in the bucket using the authorization code, run the following command:</span><p><pre class="screen" id="obs_11_0069__screen91097157294">obsutil share-ls file://d:/authorizationCode.txt -ac=123456 -prefix=test/ -limit=100</pre>
<div class="note" id="obs_11_0069__note3125169355"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_11_0069__ul686313373617"><li id="obs_11_0069__li08636311368">If the value of <strong id="obs_11_0069__b1478055111220">prefix</strong> is not specified, all objects in the authorized path are listed by default. If you do not want to list all objects, set <strong id="obs_11_0069__b126220681419">prefix</strong> to a subset of the authorized path in the authorization code.</li><li id="obs_11_0069__li14363189382">For details about this command, see <a href="obs_11_0063.html">Listing Objects by Using an Authorization Code</a>.</li></ul>
</div></div>
</p></li><li id="obs_11_0069__li157711810202913"><span>Run the <strong id="obs_11_0069__b115292064814">obsutil share-cp</strong> command to download objects from the bucket. For example, if you want to download all objects in the <strong id="obs_11_0069__b11996111817490">sub</strong> subdirectory of the <strong id="obs_11_0069__b2666141417493">test</strong> directory, run the following command:</span><p><pre class="screen" id="obs_11_0069__screen14727165313398">obsutil share-cp file://d:/authorizationCode.txt ./ -ac=123456 -key=test/sub/ -r -f</pre>
<div class="note" id="obs_11_0069__note11341220412"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0069__p141319125412">For details about this command, see <a href="obs_11_0064.html">Downloading Objects by Using an Authorization Code</a>.</p>
</div></div>
</p></li></ol>
<div class="note" id="obs_11_0069__note13220185044211"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_11_0069__ul156854527437"><li id="obs_11_0069__li11685145244311">You can also create an authorization code on OBS Console or OBS Browser, and then use obsutil to list and download objects.</li><li id="obs_11_0069__li6291165494313">You can use obsutil to create an authorization code and enter the authorization code in the address box of a web browser to list and download objects, or use the authorization code to log in to OBS Browser to list and download objects.</li></ul>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0033.html">Best Practices</a></div>
</div>
</div>