OBS C SDK Version

Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
This commit is contained in:
2025-11-21 11:26:03 +00:00
committed by zuul
parent e18658dde8
commit 22397bca9e
127 changed files with 150285 additions and 0 deletions

1895
docs/obs_3rd_party/c_sdk/ALL_META.TXT.json vendored Normal file

File diff suppressed because it is too large Load Diff

947
docs/obs_3rd_party/c_sdk/CLASS.TXT.json vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
version=""
language="en-us"
type=""

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
<a name="obs_20_0004"></a><a name="obs_20_0004"></a>
<h1 class="topictitle1">Downloading and Installing the SDK</h1>
<div id="body52842964"><p id="obs_20_0004__p37332884515">This section provides the download and compilation methods for the OBS SDK for C.</p>
<div class="section" id="obs_20_0004__section784814124610"><h4 class="sectiontitle">SDK Download</h4><ul id="obs_20_0004__ul57699577"><li id="obs_20_0004__li3783937813">Latest version of OBS C SDK source code: Click <a href="https://github.com/opentelekomcloud-community/obs-c-sdk" target="_blank" rel="noopener noreferrer">here</a> to download.</li></ul>
</div>
<div class="section" id="obs_20_0004__section169701618204616"><h4 class="sectiontitle">SDK Compilation</h4><p id="obs_20_0004__p8060118">You can compile the SDK based on the platform you are using. Before that, you must obtain the <a href="https://github.com/opentelekomcloud-community/obs-c-sdk" target="_blank" rel="noopener noreferrer">SDK source code</a>.</p>
<ul id="obs_20_0004__ul9914521261"><li id="obs_20_0004__li6917521262">In Linux:</li></ul>
<p id="obs_20_0004__p3464181711562">Go to the <strong id="obs_20_0004__b1047775818444">source/eSDK_OBS_API/eSDK_OBS_API_C++/</strong> directory and run the following script:</p>
<p id="obs_20_0004__p32971130133117"><strong id="obs_20_0004__b17297143019311">export SPDLOG_VERSION=spdlog-1.12.0</strong></p>
<p id="obs_20_0004__p220515148213">#On an x86 server, run the following command:</p>
<p id="obs_20_0004__p23731235113113"><strong id="obs_20_0004__b1937343583112">bash build.sh sdk</strong></p>
<p id="obs_20_0004__p527993933110">#On an Arm server, run the following command:</p>
<p id="obs_20_0004__p17470115815217"><strong id="obs_20_0004__b75913212311">bash build_aarch.sh</strong><strong id="obs_20_0004__b3799657172211"> sdk</strong></p>
<p id="obs_20_0004__p10348691671">For details about the parameters, see the comments in the scripts. A <strong id="obs_20_0004__b11186124410457">sdk.tgz</strong> demo package that contains the content shown below is generated.</p>
<p id="obs_20_0004__p5703173316128"><span><img id="obs_20_0004__image27257544126" src="en-us_image_0000002092648565.png"></span></p>
<ul id="obs_20_0004__ul11248246365"><li id="obs_20_0004__li11248104612614">In Windows:</li></ul>
<p id="obs_20_0004__p9776519121315">Use Visual Studio to open the <strong id="obs_20_0004__b55498554475">sln</strong> file in <strong id="obs_20_0004__b9549165584714">source/eSDK_OBS_API/eSDK_OBS_API_C++/sln/vc100/</strong> and generate the <strong id="obs_20_0004__b17550655154718">obs</strong> project. Then, <strong id="obs_20_0004__b1555125514719">securec.lib</strong>, <strong id="obs_20_0004__b555115524715">securec.dll</strong>, <strong id="obs_20_0004__b55513555476">libeSDKOBS.lib</strong>, and <strong id="obs_20_0004__b11551135511472">libeSDKOBS.dll</strong> are generated in the output directory (which can be queried in the project properties).</p>
</div>
</div>
<div></div>

View File

@ -0,0 +1,27 @@
<a name="obs_20_0100"></a><a name="obs_20_0100"></a>
<h1 class="topictitle1">Getting Started</h1>
<div id="body14940377"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="obs_20_0103.html">Creating Access Keys</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0104.html">Obtaining Endpoints</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_1805.html">Initializing the SDK</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0105.html">Initializing option</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0106.html">Creating a Bucket</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0107.html">Uploading an Object</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0108.html">Downloading an Object</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0109.html">Listing Objects</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0110.html">Deleting an Object</a></strong><br>
</li>
</ul>
</div>

View File

@ -0,0 +1,42 @@
<a name="obs_20_0101"></a><a name="obs_20_0101"></a>
<h1 class="topictitle1">Before You Start</h1>
<div id="body1536574114486"><p id="obs_20_0101__p1495717011372">This section describes the version compatibility and important notes about the C SDK of Object Storage Service (OBS).</p>
<div class="section" id="obs_20_0101__section8608210114313"><h4 class="sectiontitle">Compatibility</h4><ul id="obs_20_0101__ul8641501"><li id="obs_20_0101__li57012393"><strong id="obs_20_0101__b82141393242">3.*.*</strong> is compatible with <strong id="obs_20_0101__b294924014241">3.0.0</strong>.</li><li id="obs_20_0101__li43349494"><strong id="obs_20_0101__b9329132712244">3.*.*</strong> is incompatible with <strong id="obs_20_0101__b18198829202412">2.*.*</strong>.</li><li id="obs_20_0101__li54601134"><strong id="obs_20_0101__b1623131310244">3.*.*</strong> is incompatible with <strong id="obs_20_0101__b5321615132416">1.*.*</strong>.</li><li id="obs_20_0101__li71811616122412">Arm compilation environment:<pre class="screen" id="obs_20_0101__screen1357152153612">NAME="EulerOS"
VERSION="2.0 (SP8)"
ID="euleros"
ID_LIKE="rhel fedora centos"
VERSION_ID="2.0"
PRETTY_NAME="EulerOS 2.0 (SP8)"
ANSI_COLOR="0;31"</pre>
<p id="obs_20_0101__p20890192443516">Kernel version:</p>
<pre class="screen" id="obs_20_0101__screen62753819361">4.19.36-vhulk1905.1.0.h276.eulerosv2r8.aarch64</pre>
<p id="obs_20_0101__p897162817353">gcc/g++ version:</p>
<pre class="screen" id="obs_20_0101__screen1471753173619">gcc (GCC) 10.3.0/g++ (GCC) 10.3.0</pre>
</li><li id="obs_20_0101__li101061818175516">Linux compilation environment:<pre class="screen" id="obs_20_0101__screen1122115611174">NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"</pre>
<p id="obs_20_0101__p1230812496179">Kernel version:</p>
<pre class="screen" id="obs_20_0101__screen513520299222">3.10.0-957.5.1.el7.x86_64</pre>
<p id="obs_20_0101__p2025918142214">gcc/g++ version:</p>
<pre class="screen" id="obs_20_0101__screen19349165092415">gcc (GCC) 10.3.0/g++ (GCC) 10.3.0</pre>
<div class="note" id="obs_20_0101__note2060921214385"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_20_0101__p156091812123812">The required environments for compiling the SDK binary package are listed above. Compatibility is not guaranteed for other kernels and operating systems. If you need to use other operating systems or kernel versions, use the open-source code to compile on your own.</p>
</div></div>
</li></ul>
</div>
<div class="section" id="obs_20_0101__section1378153484418"><h4 class="sectiontitle">Important Notes</h4><ul id="obs_20_0101__ul1868723152214"><li id="obs_20_0101__li11687135220">Ensure that you are familiar with OBS basic concepts mentioned in the <a href="https://docs.otc.t-systems.com/en-us/usermanual/obs/en-us_topic_0045853692.html" target="_blank" rel="noopener noreferrer">Help Center</a>, such as bucket, object, region, and AK and SK.</li><li id="obs_20_0101__li12918161610228">After an API call is complete using an instance of ObsClient, view whether an exception is thrown. If no, the API call was successful. If yes, the operation failed. You can check the error information from <a href="obs_20_1602.html">SDK Error Handling</a>.</li><li id="obs_20_0101__li197551226203115">Some features are available only in some regions. If an API call returns the 405 HTTP status code, check whether the region supports this feature.</li></ul>
</div>
</div>

View File

@ -0,0 +1,23 @@
<a name="obs_20_0103"></a><a name="obs_20_0103"></a>
<h1 class="topictitle1">Creating Access Keys</h1>
<div id="body0000001935368500"><p id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_p391501314142">OBS uses the AK and SK in a user account for signature verification to make sure that only authorized accounts can access specified OBS resources. Detailed explanations about AK and SK are as follows:</p>
<ul id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_ul6369185515141"><li id="obs_20_0103__en-us_topic_0142814371_li1736955512144">An access key ID (AK) defines a user who accesses the OBS system. An AK belongs to only one user, but one user can have multiple AKs. The OBS system recognizes the users who access the system by their access key IDs.</li><li id="obs_20_0103__en-us_topic_0142814371_li10574144911511">A secret access key (SK) is the key used by users to access OBS. It is the authentication information generated based on the AK and the request header. An SK matches an AK, and they group into a pair.</li></ul>
<p id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_en-us_topic_0000001359833745_p948210412118">Access keys are classified into <a href="#obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_section563920502595">permanent access keys (AK/SK)</a> and <a href="#obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_section111622513117">temporary access keys (AK/SK and security token)</a>. Each user can create at most two permanent access keys. Temporary access keys must be used within a given validity period. Once expired, they must be requested again. For security purposes, you are advised to use temporary access keys to access OBS. If you want to use permanent access keys, periodically update them. The following describes how to obtain two types of access keys.</p>
<div class="section" id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_section563920502595"><a name="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_section563920502595"></a><a name="en-us_topic_0142815543_en-us_topic_0142814371_section563920502595"></a><h4 class="sectiontitle">Permanent Access Keys</h4><ol id="obs_20_0103__en-us_topic_0142814371_ol18257159604"><li id="obs_20_0103__en-us_topic_0142814371_li14257291801">Log in to OBS Console.</li><li id="obs_20_0103__en-us_topic_0142814371_li1257691016">In the upper right corner of the page, hover the cursor over the username and choose <strong id="obs_20_0103__en-us_topic_0142814371_b216047163215">My Credentials</strong>.</li><li id="obs_20_0103__en-us_topic_0142814371_li111081813183213">On the <strong id="obs_20_0103__en-us_topic_0142814371_b10731210143214">My Credentials</strong> page, select <strong id="obs_20_0103__en-us_topic_0142814371_b3743105327">Access Keys</strong> in the navigation pane on the left.</li><li id="obs_20_0103__en-us_topic_0142814371_li875452123217">On the <strong id="obs_20_0103__en-us_topic_0142814371_b343331193220">Access Keys</strong> page, click <strong id="obs_20_0103__en-us_topic_0142814371_b64335112328">Create Access Key</strong>.</li><li id="obs_20_0103__en-us_topic_0142814371_li425749207">In the <strong id="obs_20_0103__en-us_topic_0142814371_b103931330113618">Create Access Key</strong> dialog box that is displayed, enter the password and verification code.<div class="note" id="obs_20_0103__en-us_topic_0142814371_note132571795013"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_20_0103__en-us_topic_0142814371_ul10257391206"><li id="obs_20_0103__en-us_topic_0142814371_li4257291205">If you have not bound an email address or mobile number, enter only the password.</li><li id="obs_20_0103__en-us_topic_0142814371_li72573912011">If you have bound an email address and a mobile number, you can select the verification by either email or mobile phone.</li></ul>
</div></div>
</li><li id="obs_20_0103__en-us_topic_0142814371_li122571891011">Click <strong id="obs_20_0103__en-us_topic_0142814371_b51045254912">OK</strong>.</li><li id="obs_20_0103__en-us_topic_0142814371_li525717920018">In the <strong id="obs_20_0103__en-us_topic_0142814371_b3344226203211">Download Access Key</strong> dialog box that is displayed, click <strong id="obs_20_0103__en-us_topic_0142814371_b15344926203216">OK</strong> to save the access keys to your browser's default download path.</li><li id="obs_20_0103__en-us_topic_0142814371_li025716911017">Open the downloaded <strong id="obs_20_0103__en-us_topic_0142814371_b1342132242517">credentials.csv</strong> file to obtain the access keys (AK and SK).<div class="note" id="obs_20_0103__en-us_topic_0142814371_note2257119705"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_20_0103__en-us_topic_0142814371_ul16258149703"><li id="obs_20_0103__en-us_topic_0142814371_li6258119200">A user can create a maximum of two valid access keys.</li><li id="obs_20_0103__en-us_topic_0142814371_li10258391407">Keep the access key properly. If you click <strong id="obs_20_0103__en-us_topic_0142814371_b39791536193219">Cancel</strong> in the dialog box, the access keys will not be downloaded, and cannot be obtained later. You can re-create access keys if you need to use them.</li></ul>
</div></div>
</li></ol>
</div>
<div class="section" id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_section111622513117"><a name="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_section111622513117"></a><a name="en-us_topic_0142815543_en-us_topic_0142814371_section111622513117"></a><h4 class="sectiontitle">Temporary Access Keys</h4><p id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_p1387017162467">Temporary access keys are issued by the system and are only valid for 15 minutes to 24 hours. Once expired, they must be requested again. They follow the principle of least privilege. When a temporary AK/SK pair is used for authentication, a security token must be used at the same time.</p>
<p id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_p144221422124618">For details about how to obtain temporary access keys, see <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0097949518.html" target="_blank" rel="noopener noreferrer">Obtaining a Temporary AK/SK</a>.</p>
<p id="obs_20_0103__en-us_topic_0142815543_en-us_topic_0142814371_p5688839124010">For details about how to use temporary access keys, see <a href="obs_20_0105.html">Initializing option</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,11 @@
<a name="obs_20_0104"></a><a name="obs_20_0104"></a>
<h1 class="topictitle1">Obtaining Endpoints</h1>
<div id="body31795397"><ul id="obs_20_0104__ul384585317111"><li id="obs_20_0104__li1981154765611">You can click <a href="https://docs.otc.t-systems.com/en-us/endpoint/index.html" target="_blank" rel="noopener noreferrer">here</a> to view the endpoints and regions enabled for OBS.</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,35 @@
<a name="obs_20_0105"></a><a name="obs_20_0105"></a>
<h1 class="topictitle1">Initializing <strong id="b5676322126">option</strong></h1>
<div id="body19782132"><p class="msonormal" id="obs_20_0105__p33788941">When the function of SDK for C is called, the <strong id="obs_20_0105__b15984021163711">option</strong> parameter must be passed. You can use function <strong id="obs_20_0105__b1055319374389">init_obs_options</strong> to initialize the <strong id="obs_20_0105__b152725128396">option</strong> configuration, including the AK, SK, endpoint, bucket, timeout, and temporary authentication.</p>
<ul id="obs_20_0105__ul833716123111"><li id="obs_20_0105__li32892711110">Sample code for creating and initializing <strong id="obs_20_0105__b1056483313555">option</strong> using permanent access keys (AK/SK):<pre class="screen" id="obs_20_0105__screen4511144152617">// Create and initialize <strong id="obs_20_0105__b172491146203811">option</strong>.
obs_options option;
init_obs_options(&amp;option);
option.bucket_options.host_name = "&lt;your-endpoint&gt;";
option.bucket_options.bucket_name = "&lt;Your bucketname&gt;";
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0105__b1960347181215">ACCESS_KEY_ID</strong> and <strong id="obs_20_0105__b99601472122">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");</pre>
</li><li id="obs_20_0105__li2029212716115">Sample code for creating and initializing <strong id="obs_20_0105__b57016795710">option</strong> using temporary access keys (AK/SK and SecurityToken):<pre class="screen" id="obs_20_0105__screen160631161119">// Create and initialize <strong id="obs_20_0105__b1914210408573">option</strong>.
obs_options option;
init_obs_options(&amp;option);
option.bucket_options.host_name = "&lt;your-endpoint&gt;";
option.bucket_options.bucket_name = "&lt;Your bucketname&gt;";
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0105__b184905042918">ACCESS_KEY_ID</strong> and <strong id="obs_20_0105__b949013032917">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
option.bucket_options.token = getenv("SecurityToken");</pre>
<div class="note" id="obs_20_0105__note50970094"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_20_0105__ul14966202091713"><li id="obs_20_0105__li39641320131716">OBS is a global service. When obtaining temporary credentials, set the token scope to <strong id="obs_20_0105__b29091321406">domain</strong> to make the token applicable to all projects and regions within an account.</li></ul>
</div></div>
</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,47 @@
<a name="obs_20_0106"></a><a name="obs_20_0106"></a>
<h1 class="topictitle1">Creating a Bucket</h1>
<div id="body14818902"><p class="MsoNormal" id="obs_20_0106__p133641747104">A bucket is a global namespace of OBS and is a data container. It functions as a root directory of a file system and can store objects.</p>
<div class="MsoNormal" id="obs_20_0106__p35796626">Sample code:<pre class="screen" id="obs_20_0106__screen53734179">static void test_create_bucket<strong id="obs_20_0106__b142413342311">(</strong>obs_canned_acl canned_acl<strong id="obs_20_0106__b1242418316236">,</strong> char <strong id="obs_20_0106__b14424113152315">*</strong>bucket_name<strong id="obs_20_0106__b44249372310">)</strong>
<strong id="obs_20_0106__b342413352317">{</strong>
obs_status ret_status <strong id="obs_20_0106__b1425113132319">=</strong> OBS_STATUS_BUTT<strong id="obs_20_0106__b184258317234">;</strong>
// Create and initialize <strong id="obs_20_0106__b477534218473">option</strong>.
obs_options option<strong id="obs_20_0106__b1342510317235">;</strong>
init_obs_options<strong id="obs_20_0106__b74251313233">(&amp;</strong>option<strong id="obs_20_0106__b1142513319239">);</strong>
option.bucket_options.host_name<strong id="obs_20_0106__b4425036239"></strong><strong id="obs_20_0106__b64252392319"></strong> <strong id="obs_20_0106__b24259322319">=</strong> "&lt;your-endpoint&gt;"<strong id="obs_20_0106__b20425034237">;</strong>
option.bucket_options.bucket_name<strong id="obs_20_0106__b164256315231"></strong><strong id="obs_20_0106__b1542503182314"></strong> <strong id="obs_20_0106__b942516312312">=</strong> "&lt;Your bucketname&gt;"<strong id="obs_20_0106__b5426832235">;</strong>
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0106__b2455332086">ACCESS_KEY_ID</strong> and <strong id="obs_20_0106__b1445543982">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
// Set the response callback function.
obs_response_handler response_handler <strong id="obs_20_0106__b10426153132318">=</strong>
<strong id="obs_20_0106__b184269314237">{</strong>
0<strong id="obs_20_0106__b10426335236">,</strong> <strong id="obs_20_0106__b134267352319">&amp;</strong>response_complete_callback
<strong id="obs_20_0106__b24273382318">};</strong>
// Create a bucket. For details about pre-defined ACLs, see the section "Configuring a Bucket ACL (SDK for C)".
create_bucket<strong id="obs_20_0106__b2042723162320">(&amp;</strong>option<strong id="obs_20_0106__b174271834236">,</strong> "&lt;bucket ACL&gt;"<strong id="obs_20_0106__b174275372311">,</strong> <strong id="obs_20_0106__b1842713322316">NULL</strong><strong id="obs_20_0106__b1742716332310">,</strong> <strong id="obs_20_0106__b142719314233">&amp;</strong>response_handler<strong id="obs_20_0106__b1642793172314">,</strong> <strong id="obs_20_0106__b44278312233">&amp;</strong>ret_status<strong id="obs_20_0106__b64271730235">);</strong>
<strong id="obs_20_0106__b20428638233">if</strong> <strong id="obs_20_0106__b84281032238">(</strong>ret_status <strong id="obs_20_0106__b154287313232">==</strong> OBS_STATUS_OK<strong id="obs_20_0106__b642817314237">)</strong> <strong id="obs_20_0106__b1542843152311">{</strong>
printf<strong id="obs_20_0106__b742873142319">(</strong>"create bucket successfully. \n"<strong id="obs_20_0106__b1428337237">);</strong>
<strong id="obs_20_0106__b1429143112312">}</strong>
<strong id="obs_20_0106__b14429336238">else</strong>
<strong id="obs_20_0106__b104294311234">{</strong>
printf<strong id="obs_20_0106__b15429153152318">(</strong>"create bucket failed(%s).\n"<strong id="obs_20_0106__b15429234239">,</strong> obs_get_status_name<strong id="obs_20_0106__b942933182316">(</strong>ret_status<strong id="obs_20_0106__b74296312312">));</strong>
<strong id="obs_20_0106__b164291311236">}</strong>
<strong id="obs_20_0106__b17429193192313">}</strong></pre>
</div>
<div class="note" id="obs_20_0106__note50970094"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_20_0106__p13741225151715">Bucket names are globally unique. Ensure that the bucket you create is named differently from any other bucket. A bucket name must comply with the following rules:</p>
<ul id="obs_20_0106__ul14966202091713"><li id="obs_20_0106__li12964162013173">Contains 3 to 63 characters, starts with a digit or letter, and supports only lowercase letters, digits, hyphens (-), and periods (.)</li><li id="obs_20_0106__li39641320131716">Cannot be an IP address.</li><li id="obs_20_0106__li1496482011179">Cannot start or end with a hyphen (-) or period (.).</li><li id="obs_20_0106__li1696492018174">Cannot contain two consecutive periods (..), for example, <strong id="obs_20_0106__b597704315471">my..bucket</strong>.</li><li id="obs_20_0106__li496602081710">Cannot contain a period (.) and a hyphen (-) adjacent to each other, for example, <strong id="obs_20_0106__b654080193612">my-.bucket</strong> or <strong id="obs_20_0106__b105409015368">my.-bucket</strong>.</li><li id="obs_20_0106__li149661220171720">If you create buckets of the same name, no error will be reported and the bucket properties comply with those set in the first creation request.</li></ul>
<p id="obs_20_0106__p21017396172">The example here sets the bucket's ACL to private read and write, storage class to Standard, and location to the default region for the global domain name.</p>
<p id="obs_20_0106__p5590111815720">For more information, see <a href="obs_20_0301.html">Creating a Bucket</a>.</p>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,57 @@
<a name="obs_20_0107"></a><a name="obs_20_0107"></a>
<h1 class="topictitle1">Uploading an Object</h1>
<div id="body24858567"><p class="MsoNormal" id="obs_20_0107__p18898438123518">The data flow is saved to <strong id="obs_20_0107__b1120212426212">callback_data</strong> (see the <strong id="obs_20_0107__b82030421923">callback_data</strong> definition in <a href="obs_20_0401.html">Uploading an Object - Streaming</a>). Use the callback function <strong id="obs_20_0107__b020304219216">put_object_data_callback</strong> defined in <strong id="obs_20_0107__b72046421726">obs_put_object_handler</strong> to copy the content of the uploaded object to <strong id="obs_20_0107__b102041542121">buffer</strong>, a character pointer parameter of the callback function.</p>
<p id="obs_20_0107__p77578514363">For more information, see <a href="obs_20_0401.html">Uploading an Object - Streaming</a>.</p>
<p class="MsoNormal" id="obs_20_0107__p57735005">Sample code:</p>
<pre class="screen" id="obs_20_0107__screen28635982">static void test_put_object_from_buffer<strong id="obs_20_0107__b1013416446243">()</strong>
<strong id="obs_20_0107__b213464412414">{</strong>
// Buffer to be uploaded
char <strong id="obs_20_0107__b713584418249">*</strong>buffer <strong id="obs_20_0107__b17135104419246">=</strong> "abcdefg"<strong id="obs_20_0107__b1013514452417">;</strong>
// Length of the buffer to be uploaded
int buffer_size <strong id="obs_20_0107__b201351844152420">=</strong> strlen<strong id="obs_20_0107__b81351244132415">(</strong>buffer<strong id="obs_20_0107__b1013513449245">);</strong>
// Name of an object to be uploaded
char <strong id="obs_20_0107__b11135544192411">*</strong>key <strong id="obs_20_0107__b31351544172417">=</strong> "put_buffer_test"<strong id="obs_20_0107__b61351144182413">;</strong>
// Initialize <strong id="obs_20_0107__b9592919185117">option</strong>.
obs_options option<strong id="obs_20_0107__b9135544172411">;</strong>
init_obs_options<strong id="obs_20_0107__b101363446240">(&amp;</strong>option<strong id="obs_20_0107__b1136174411248">);</strong>
option.bucket_options.host_name<strong id="obs_20_0107__b17136124422411"></strong><strong id="obs_20_0107__b16136044202412"></strong> <strong id="obs_20_0107__b81366445244">=</strong> "&lt;your-endpoint&gt;"<strong id="obs_20_0107__b19136644192412">;</strong>
option.bucket_options.bucket_name<strong id="obs_20_0107__b15136174482415"></strong><strong id="obs_20_0107__b9136124442416"></strong> <strong id="obs_20_0107__b1813644482410">=</strong> "&lt;Your bucket name&gt;"<strong id="obs_20_0107__b1313634419244">;</strong>
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0107__b395417304812">ACCESS_KEY_ID</strong> and <strong id="obs_20_0107__b395413301685">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
// Initialize the properties of an object to be uploaded.
obs_put_properties put_properties<strong id="obs_20_0107__b01371744132413">;</strong>
init_put_properties<strong id="obs_20_0107__b201371744192418">(&amp;</strong>put_properties<strong id="obs_20_0107__b19137194413241">);</strong>
// Customize the structure for storing uploaded data.
put_buffer_object_callback_data data<strong id="obs_20_0107__b1613710440249">;</strong>
memset<strong id="obs_20_0107__b7137444102414">(&amp;</strong>data<strong id="obs_20_0107__b171371344192418">,</strong> 0<strong id="obs_20_0107__b6137344122412">,</strong> <strong id="obs_20_0107__b1613734419245">sizeof</strong><strong id="obs_20_0107__b18138104414248">(</strong>put_buffer_object_callback_data<strong id="obs_20_0107__b013811446246">));</strong>
// Assign the buffer value to the structure.
data<strong id="obs_20_0107__b11138044132411">.</strong>put_buffer <strong id="obs_20_0107__b81382044142412">=</strong> buffer<strong id="obs_20_0107__b171381444142416">;</strong>
// Set buffersize.
data<strong id="obs_20_0107__b213804482410">.</strong>buffer_size <strong id="obs_20_0107__b6138344142413">=</strong> buffer_size<strong id="obs_20_0107__b813874418248">;</strong>
// Set the callback function. The corresponding callback function needs to be implemented.
obs_put_object_handler putobjectHandler <strong id="obs_20_0107__b6139204419246">=</strong>
<strong id="obs_20_0107__b1413910442249">{</strong>
<strong id="obs_20_0107__b16139134410247">{</strong> <strong id="obs_20_0107__b19139744162419">&amp;</strong>response_properties_callback<strong id="obs_20_0107__b16139164422413">,</strong> <strong id="obs_20_0107__b1139184415248">&amp;</strong>put_buffer_complete_callback <strong id="obs_20_0107__b813934414249">},</strong>
<strong id="obs_20_0107__b171401044172411">&amp;</strong>put_buffer_data_callback
<strong id="obs_20_0107__b614084412410">};</strong>
put_object<strong id="obs_20_0107__b141401944182419">(&amp;</strong>option<strong id="obs_20_0107__b1614017442245">,</strong> key<strong id="obs_20_0107__b2140194412410">,</strong> buffer_size<strong id="obs_20_0107__b101401544172413">,</strong> <strong id="obs_20_0107__b314016445247">&amp;</strong>put_properties<strong id="obs_20_0107__b10140244132411">,</strong>0<strong id="obs_20_0107__b214014442414">,&amp;</strong>putobjectHandler<strong id="obs_20_0107__b114054411243">,&amp;</strong>data<strong id="obs_20_0107__b121401444142418">);</strong>
<strong id="obs_20_0107__b614084410248">if</strong> <strong id="obs_20_0107__b15140114422413">(</strong>OBS_STATUS_OK <strong id="obs_20_0107__b1814015449244">==</strong> data<strong id="obs_20_0107__b214015449243">.</strong>ret_status<strong id="obs_20_0107__b161402448244">)</strong> <strong id="obs_20_0107__b16140844152417">{</strong>
printf<strong id="obs_20_0107__b0140184416244">(</strong>"put object from buffer successfully. \n"<strong id="obs_20_0107__b13140134413245">);</strong>
<strong id="obs_20_0107__b1714044482415">}</strong>
<strong id="obs_20_0107__b2140154418249">else</strong>
<strong id="obs_20_0107__b914054418244">{</strong>
printf<strong id="obs_20_0107__b12140104418241">(</strong>"put object from buffer failed(%s).\n"<strong id="obs_20_0107__b8142134402419">,</strong> obs_get_status_name<strong id="obs_20_0107__b181421544122411">(</strong>data<strong id="obs_20_0107__b0142154411241">.</strong>ret_status<strong id="obs_20_0107__b1714274422411">));</strong>
<strong id="obs_20_0107__b1114204414242">}</strong>
<strong id="obs_20_0107__b161424446241">}</strong></pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,55 @@
<a name="obs_20_0108"></a><a name="obs_20_0108"></a>
<h1 class="topictitle1">Downloading an Object</h1>
<div id="body52340781"><p class="MsoNormal" id="obs_20_0108__p0103140101517">This example shows how to download an object from a bucket to a directory and save the object as <strong id="obs_20_0108__b151513973719">test</strong>.</p>
<p class="MsoNormal" id="obs_20_0108__p48250401">Sample code:</p>
<pre class="screen" id="obs_20_0108__screen31600429">static void test_get_object<strong id="obs_20_0108__b23794022617">()</strong>
<strong id="obs_20_0108__b137950102614">{</strong>
char <strong id="obs_20_0108__b15380308264">*</strong>file_name <strong id="obs_20_0108__b3380150122616">=</strong> "./test"<strong id="obs_20_0108__b43803013264">;</strong>
obs_object_info object_info<strong id="obs_20_0108__b13806022616">;</strong>
// Initialize <strong id="obs_20_0108__b35023497317">option</strong>.
obs_options option<strong id="obs_20_0108__b1038050182610">;</strong>
init_obs_options<strong id="obs_20_0108__b1038050122612">(&amp;</strong>option<strong id="obs_20_0108__b1838000172619">);</strong>
option.bucket_options.host_name<strong id="obs_20_0108__b1738010132618"></strong><strong id="obs_20_0108__b7380807266"></strong> <strong id="obs_20_0108__b73801905266">=</strong> "&lt;your-endpoint&gt;"<strong id="obs_20_0108__b133802012618">;</strong>
option.bucket_options.bucket_name<strong id="obs_20_0108__b7380120142612"></strong><strong id="obs_20_0108__b173801802269"></strong> <strong id="obs_20_0108__b193810012614">=</strong> "&lt;Your bucketname&gt;"<strong id="obs_20_0108__b138170202611">;</strong>
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0108__b38604010311027">ACCESS_KEY_ID</strong> and <strong id="obs_20_0108__b198326131011027">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
// Set the object to be downloaded.
memset<strong id="obs_20_0108__b438117013260">(&amp;</strong>object_info<strong id="obs_20_0108__b1438140192612">,</strong> 0<strong id="obs_20_0108__b338210132613">,</strong> <strong id="obs_20_0108__b7382608262">sizeof</strong><strong id="obs_20_0108__b1538210042615">(</strong>obs_object_info<strong id="obs_20_0108__b17382301260">));</strong>
object_info<strong id="obs_20_0108__b1338215072619">.</strong>key <strong id="obs_20_0108__b438215082618">=</strong> "&lt;object key&gt;"<strong id="obs_20_0108__b1738220017267">;</strong>
object_info<strong id="obs_20_0108__b564221918281">.</strong>version_id <strong id="obs_20_0108__b1164217193283">=</strong> "&lt;object version ID&gt;";
// Customize the structure for storing downloaded object data based on service requirements.
get_object_callback_data data<strong id="obs_20_0108__b43825042617">;</strong>
data<strong id="obs_20_0108__b138214014263">.</strong>ret_status <strong id="obs_20_0108__b8382140142615">=</strong> OBS_STATUS_BUTT<strong id="obs_20_0108__b17382190172612">;</strong>
data<strong id="obs_20_0108__b113821304262">.</strong>outfile <strong id="obs_20_0108__b438210172611">=</strong> write_to_file<strong id="obs_20_0108__b1538390152616">(</strong>file_name<strong id="obs_20_0108__b638314092611">);</strong>
// Define range download parameters.
obs_get_conditions getcondition<strong id="obs_20_0108__b638340192614">;</strong>
memset<strong id="obs_20_0108__b63831107260">(&amp;</strong>getcondition<strong id="obs_20_0108__b193831803261">,</strong> 0<strong id="obs_20_0108__b20383200267">,</strong> <strong id="obs_20_0108__b1838316019262">sizeof</strong><strong id="obs_20_0108__b1638317020261">(</strong>obs_get_conditions<strong id="obs_20_0108__b173836015264">));</strong>
init_get_properties<strong id="obs_20_0108__b93833011267">(&amp;</strong>getcondition<strong id="obs_20_0108__b738417072610">);</strong>
// Customize callback function for download.
obs_get_object_handler get_object_handler <strong id="obs_20_0108__b143841908263">=</strong>
<strong id="obs_20_0108__b53846012612">{</strong>
<strong id="obs_20_0108__b13841603260">{</strong> <strong id="obs_20_0108__b4384700268">&amp;</strong>response_properties_callback<strong id="obs_20_0108__b43845062611">,</strong> <strong id="obs_20_0108__b19384200122614">&amp;</strong>get_object_complete_callback<strong id="obs_20_0108__b1538420019265">},</strong>
<strong id="obs_20_0108__b93852013266">&amp;</strong>get_object_data_callback
<strong id="obs_20_0108__b163851805269">};</strong>
get_object<strong id="obs_20_0108__b1138520112613">(&amp;</strong>option<strong id="obs_20_0108__b738520182616">,</strong> <strong id="obs_20_0108__b83851803265">&amp;</strong>object_info<strong id="obs_20_0108__b938512022613">,</strong> <strong id="obs_20_0108__b43851005263">&amp;</strong>getcondition<strong id="obs_20_0108__b1938550122617">,</strong> 0<strong id="obs_20_0108__b03855020261">,</strong> <strong id="obs_20_0108__b13386605262">&amp;</strong>get_object_handler<strong id="obs_20_0108__b1438640202617">,</strong> <strong id="obs_20_0108__b3386100192612">&amp;</strong>data<strong id="obs_20_0108__b1138613018261">);</strong>
<strong id="obs_20_0108__b13869020263">if</strong> <strong id="obs_20_0108__b163862016261">(</strong>OBS_STATUS_OK <strong id="obs_20_0108__b1438616022614">==</strong> data<strong id="obs_20_0108__b17386120122613">.</strong>ret_status<strong id="obs_20_0108__b19386909262">)</strong> <strong id="obs_20_0108__b19386110192611">{</strong>
printf<strong id="obs_20_0108__b10386110122616">(</strong>"get object successfully. \n"<strong id="obs_20_0108__b183873015263">);</strong>
<strong id="obs_20_0108__b2038780202614">}</strong>
<strong id="obs_20_0108__b7387909261">else</strong>
<strong id="obs_20_0108__b43871806267">{</strong>
printf<strong id="obs_20_0108__b19387130172618">(</strong>"get object failed(%s).\n"<strong id="obs_20_0108__b183871407269">,</strong> obs_get_status_name<strong id="obs_20_0108__b33872018265">(</strong>data<strong id="obs_20_0108__b938817011264">.</strong>ret_status<strong id="obs_20_0108__b1438880142616">));</strong>
<strong id="obs_20_0108__b6388130202612">}</strong>
fclose<strong id="obs_20_0108__b938890102617">(</strong>data<strong id="obs_20_0108__b2388309269">.</strong>outfile<strong id="obs_20_0108__b138890162617">);</strong>
<strong id="obs_20_0108__b18388100152616">}</strong></pre>
<div class="note" id="obs_20_0108__note16153123814124"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_20_0108__p131531138151210">For more information, see <a href="obs_20_0501.html">Downloading an Object</a>.</p>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,48 @@
<a name="obs_20_0109"></a><a name="obs_20_0109"></a>
<h1 class="topictitle1">Listing Objects</h1>
<div id="body63906945"><p class="notesheading" id="obs_20_0109__p65723630">This example shows how to list all objects in a bucket.</p>
<p id="obs_20_0109__p104161832201714">Sample code:</p>
<pre class="screen" id="obs_20_0109__screen21702786">static void test_list_bucket_objects<strong id="obs_20_0109__b5554575612">(</strong><strong id="obs_20_0109__b15551857061">)</strong>
<strong id="obs_20_0109__b11551757669">{</strong>
// Create and initialize <strong id="obs_20_0109__b3452235113916">option</strong>.
obs_options option<strong id="obs_20_0109__b155575713613">;</strong>
init_obs_options<strong id="obs_20_0109__b115513571160">(&amp;</strong>option<strong id="obs_20_0109__b145513574617">);</strong>
option.bucket_options.host_name<strong id="obs_20_0109__b135514571369"></strong><strong id="obs_20_0109__b7552576617"></strong> <strong id="obs_20_0109__b45510571360">=</strong> "&lt;your-endpoint&gt;"<strong id="obs_20_0109__b19550571360">;</strong>
option.bucket_options.bucket_name<strong id="obs_20_0109__b05513571068"></strong><strong id="obs_20_0109__b16562571765"></strong> <strong id="obs_20_0109__b20561057967">=</strong> "&lt;Your bucketname&gt;"<strong id="obs_20_0109__b2569574613">;</strong>
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0109__b729833525198">ACCESS_KEY_ID</strong> and <strong id="obs_20_0109__b839004678198">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
// Set response callback function.
obs_list_objects_handler list_bucket_objects_handler <strong id="obs_20_0109__b185818571619">=</strong>
<strong id="obs_20_0109__b145817571768">{</strong>
<strong id="obs_20_0109__b6584578619">{</strong> <strong id="obs_20_0109__b17582571869">&amp;</strong>response_properties_callback<strong id="obs_20_0109__b55818574619">,</strong> <strong id="obs_20_0109__b1658165715616">&amp;</strong>list_objects_complete_callback <strong id="obs_20_0109__b35814579613">},</strong>
<strong id="obs_20_0109__b16583576618">&amp;</strong>list_objects_callback
<strong id="obs_20_0109__b135865712614">};</strong>
// Customize callback data.
list_bucket_callback_data data<strong id="obs_20_0109__b145810576613">;</strong>
memset<strong id="obs_20_0109__b1358357069">(&amp;</strong>data<strong id="obs_20_0109__b1658657966">,</strong> 0<strong id="obs_20_0109__b12582057565">,</strong> <strong id="obs_20_0109__b145820571568">sizeof</strong><strong id="obs_20_0109__b1583571615">(</strong>list_bucket_callback_data<strong id="obs_20_0109__b85814575613">));</strong>
// List objects.
list_bucket_objects<strong id="obs_20_0109__b5581571764">(&amp;</strong>option<strong id="obs_20_0109__b7581571066">,</strong> "&lt;prefix&gt;"<strong id="obs_20_0109__b17581557963">,</strong> "&lt;marker&gt;"<strong id="obs_20_0109__b35813575616">,</strong> "&lt;delimiter&gt;"<strong id="obs_20_0109__b12581257960">,</strong> "&lt;maxkeys&gt;"<strong id="obs_20_0109__b135835720610">,</strong> <strong id="obs_20_0109__b1058125719615">&amp;</strong>list_bucket_objects_handler<strong id="obs_20_0109__b1458175712611">,</strong> <strong id="obs_20_0109__b15805718617">&amp;</strong>data<strong id="obs_20_0109__b205816571467">);</strong>
<strong id="obs_20_0109__b358115714619">if</strong> <strong id="obs_20_0109__b13589576615">(</strong>OBS_STATUS_OK <strong id="obs_20_0109__b1558957264">==</strong> data<strong id="obs_20_0109__b05816576610">.</strong>ret_status<strong id="obs_20_0109__b205895720610">)</strong> <strong id="obs_20_0109__b155815579612">{</strong>
printf<strong id="obs_20_0109__b55817573613">(</strong>"list bucket objects successfully. \n"<strong id="obs_20_0109__b15589571063">);</strong>
<strong id="obs_20_0109__b558145717617">}</strong>
<strong id="obs_20_0109__b165825718617">else</strong>
<strong id="obs_20_0109__b1586574612">{</strong>
printf<strong id="obs_20_0109__b11581057065">(</strong>"list bucket objects failed(%s).\n"<strong id="obs_20_0109__b4586572613">,</strong>
obs_get_status_name<strong id="obs_20_0109__b1458357865">(</strong>data<strong id="obs_20_0109__b15586570610">.</strong>ret_status<strong id="obs_20_0109__b6581857262">));</strong>
<strong id="obs_20_0109__b7584578613">}</strong>
<strong id="obs_20_0109__b45816579612">}</strong></pre>
<div class="note" id="obs_20_0109__note41796547"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_20_0109__ul40624608"><li id="obs_20_0109__li30077156">For more information, see <a href="obs_20_0603.html">Listing Objects in a Bucket</a>.</li></ul>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,48 @@
<a name="obs_20_0110"></a><a name="obs_20_0110"></a>
<h1 class="topictitle1">Deleting an Object</h1>
<div id="body27604160"><p class="notesheading" id="obs_20_0110__p65723630">This example shows how to delete an object from a bucket.</p>
<p id="obs_20_0110__p104161832201714">Sample code:</p>
<pre class="screen" id="obs_20_0110__screen21702786">static void test_delete_object<strong id="obs_20_0110__b164818554914">(</strong><strong id="obs_20_0110__b164813553919">)</strong>
<strong id="obs_20_0110__b5649155512912">{</strong>
obs_status ret_status <strong id="obs_20_0110__b1764919551293">=</strong> OBS_STATUS_BUTT<strong id="obs_20_0110__b16491055492">;</strong>
// Create and initialize object information.
obs_object_info object_info<strong id="obs_20_0110__b1264912558912">;</strong>
memset<strong id="obs_20_0110__b18649175519912">(&amp;</strong>object_info<strong id="obs_20_0110__b1064917559918">,</strong> 0<strong id="obs_20_0110__b6649355399">,</strong> <strong id="obs_20_0110__b46491655494">sizeof</strong><strong id="obs_20_0110__b4649055192">(</strong>obs_object_info<strong id="obs_20_0110__b1649135515914">));</strong>
object_info<strong id="obs_20_0110__b18649175510911">.</strong>key <strong id="obs_20_0110__b156499551493">=</strong> "&lt;Your Key&gt;"<strong id="obs_20_0110__b964917551397">;</strong>
// Create and initialize <strong id="obs_20_0110__b57651524183916">option</strong>.
obs_options option<strong id="obs_20_0110__b1564955514912">;</strong>
init_obs_options<strong id="obs_20_0110__b156501455693">(&amp;</strong>option<strong id="obs_20_0110__b56504551795">);</strong>
option.bucket_options.host_name<strong id="obs_20_0110__b2065025513920"></strong><strong id="obs_20_0110__b12650255396"></strong> <strong id="obs_20_0110__b116505551495">=</strong> "&lt;your-endpoint&gt;"<strong id="obs_20_0110__b9650355897">;</strong>
option.bucket_options.bucket_name<strong id="obs_20_0110__b1065016551497"></strong><strong id="obs_20_0110__b56503551593"></strong> <strong id="obs_20_0110__b765014556916">=</strong> "&lt;Your bucketname&gt;"<strong id="obs_20_0110__b196502055993">;</strong>
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables <strong id="obs_20_0110__b12891554281948">ACCESS_KEY_ID</strong> and <strong id="obs_20_0110__b2261323811948">SECRET_ACCESS_KEY</strong>.
// Obtain an AK/SK pair on the management console.
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
// Set response callback function.
obs_response_handler responseHandler <strong id="obs_20_0110__b1565015513917">=</strong>
<strong id="obs_20_0110__b1265016551493">{</strong>
<strong id="obs_20_0110__b965017551693">&amp;</strong>response_properties_callback<strong id="obs_20_0110__b12650185510912">,</strong>
<strong id="obs_20_0110__b3650145515915">&amp;</strong>response_complete_callback
<strong id="obs_20_0110__b116506559914">};</strong>
// Delete an object.
delete_object<strong id="obs_20_0110__b1065018552911">(&amp;</strong>option<strong id="obs_20_0110__b16650455698">,&amp;</strong>object_info<strong id="obs_20_0110__b66507552098">,&amp;</strong>responseHandler<strong id="obs_20_0110__b16509551392">,</strong> <strong id="obs_20_0110__b1865016554914">&amp;</strong>ret_status<strong id="obs_20_0110__b18650055792">);</strong>
<strong id="obs_20_0110__b166506551893">if</strong> <strong id="obs_20_0110__b96508558913">(</strong>OBS_STATUS_OK <strong id="obs_20_0110__b865015551295">==</strong> ret_status<strong id="obs_20_0110__b4651145516910">)</strong>
<strong id="obs_20_0110__b765114552911">{</strong>
printf<strong id="obs_20_0110__b126511655397">(</strong>"delete object successfully. \n"<strong id="obs_20_0110__b965113551299">);</strong>
<strong id="obs_20_0110__b1965115518914">}</strong>
<strong id="obs_20_0110__b1865110553913">else</strong>
<strong id="obs_20_0110__b9651955795">{</strong>
printf<strong id="obs_20_0110__b2651135516910">(</strong>"delete object failed(%s).\n"<strong id="obs_20_0110__b166516551299">,</strong> obs_get_status_name<strong id="obs_20_0110__b14651105513915">(</strong>ret_status<strong id="obs_20_0110__b665115518917">));</strong>
<strong id="obs_20_0110__b1865116551892">}</strong>
<strong id="obs_20_0110__b1965113558919">}</strong></pre>
<div class="note" id="obs_20_0110__note41796547"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_20_0110__ul40624608"><li id="obs_20_0110__li30077156">For more information, see <a href="obs_20_0604.html">Deleting an Object</a>.</li></ul>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0100.html">Getting Started</a></div>
</div>
</div>

View File

@ -0,0 +1,17 @@
<a name="obs_20_0200"></a><a name="obs_20_0200"></a>
<h1 class="topictitle1">Initialization</h1>
<div id="body5789337"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="obs_20_0201.html">Configuring Access Keys</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0202.html">Initializing the SDK</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0203.html">Configuring option</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0204.html">Configuring SDK Logging</a></strong><br>
</li>
</ul>
</div>

View File

@ -0,0 +1,13 @@
<a name="obs_20_0201"></a><a name="obs_20_0201"></a>
<h1 class="topictitle1">Configuring Access Keys</h1>
<div id="body18068793"><p class="MsoNormal" id="obs_20_0201__p5873884">To use OBS, you need a valid pair of AK and SK for signature authentication. For details, see <a href="obs_20_0103.html">Creating Access Keys</a>.</p>
<p class="MsoNormal" id="obs_20_0201__p52864961">After obtaining the AK and SK, you can start initialization.</p>
<ul id="obs_20_0201__ul1440211322910"><li id="obs_20_0201__li140233214919"><a href="obs_20_0202.html">Initializing the SDK</a></li><li id="obs_20_0201__li1040215321999"><a href="obs_20_0203.html">Configuring option</a></li><li id="obs_20_0201__li040210321197"><a href="obs_20_0204.html">Configuring SDK Logging</a></li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0200.html">Initialization</a></div>
</div>
</div>

View File

@ -0,0 +1,22 @@
<a name="obs_20_0202"></a><a name="obs_20_0202"></a>
<h1 class="topictitle1">Initializing the SDK</h1>
<div id="body57568113"><p id="obs_20_0202__p193959486419"><strong id="obs_20_0202__b842352706153732">ObsClient</strong> functions as the C client for accessing OBS. It offers callers a series of APIs for interaction with OBS. These APIs are used for managing and operating resources, such as buckets and objects, stored in OBS.</p>
<p id="obs_20_0202__p144073682820">Before using the OBS C SDK to initiate an OBS request, you need to call the initialization API. When you are exiting the process, you need to call the initialization cancellation API to release resources.</p>
<p class="msonormal" id="obs_20_0202__p15040325">Before using the C SDK, you must first call <strong id="obs_20_0202__b6657143281018">obs_initialize</strong> to complete the initialization. This API only needs to called once in a process.</p>
<pre class="screen" id="obs_20_0202__screen1145198">obs_status ret_status <strong id="obs_20_0202__b17288210151919">=</strong> OBS_STATUS_BUTT<strong id="obs_20_0202__b62891210111916">;</strong>
ret_status <strong id="obs_20_0202__b1328971018196">=</strong> obs_initialize<strong id="obs_20_0202__b1828921015195">(</strong>OBS_INIT_ALL<strong id="obs_20_0202__b11289131091916">);</strong>
<strong id="obs_20_0202__b192903103194">if</strong> <strong id="obs_20_0202__b1029015104191">(</strong>OBS_STATUS_OK <strong id="obs_20_0202__b4290131016197">!=</strong> ret_status<strong id="obs_20_0202__b6290161010194">)</strong>
<strong id="obs_20_0202__b429191071917">{</strong>
printf<strong id="obs_20_0202__b192911610181915">(</strong>"obs_initialize failed(%s).\n"<strong id="obs_20_0202__b529241051914">,</strong> obs_get_status_name<strong id="obs_20_0202__b92921210131915">(</strong>ret_status<strong id="obs_20_0202__b142921310101916">));</strong>
<strong id="obs_20_0202__b15293610121917">return</strong> ret_status<strong id="obs_20_0202__b172931210161915">;</strong>
<strong id="obs_20_0202__b16293191071912">}</strong>
obs_deinitialize();
// Do not repeatedly call <strong id="obs_20_0202__b8645125332512">obs_initialize</strong> or <strong id="obs_20_0202__b6657413112618">obs_deinitialize</strong>, because these operations may lead to invalid memory access.</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0200.html">Initialization</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
<a name="obs_20_0204"></a><a name="obs_20_0204"></a>
<h1 class="topictitle1">Configuring SDK Logging</h1>
<div id="body58269279"><p class="msonormal" id="obs_20_0204__p15361235">The OBS C SDK log path is specified by the <strong id="obs_20_0204__b191801859101216">LogPath</strong> field in <strong id="obs_20_0204__b20180759141218">OBS.ini</strong>. By default, logs are stored in the <strong id="obs_20_0204__b2180459141219">logs</strong> directory at the same level as the <strong id="obs_20_0204__b11180145918128">lib</strong> directory of the C SDK dynamic library. <strong id="obs_20_0204__b8180155911211">OBS.ini</strong> must be in the same directory as <strong id="obs_20_0204__b201804595127">libeSDKLogAPI.so</strong>.</p>
<p id="obs_20_0204__p17892599245">The OBS C SDK allows you to use <strong id="obs_20_0204__b1364152718137">set_obs_log_path</strong> to specify a log path. This method has two parameters. The first parameter specifies a path and the second determines what to do under the path. If the second parameter is set to <strong id="obs_20_0204__b33641127181314">True</strong>, the SDK searches for <strong id="obs_20_0204__b13364132781315">OBS.ini</strong> in the path specified by the first parameter for log configuration. If the second parameter is set to <strong id="obs_20_0204__b183641627121320">False</strong>, the SDK generates <strong id="obs_20_0204__b1336415271138">OBS.ini</strong> and log files in the path specified by the first parameter.</p>
<div class="note" id="obs_20_0204__note4230893"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_20_0204__ul1934525210504"><li id="obs_20_0204__li83451052165019">For details about SDK logging, see <a href="obs_20_1603.html">Log Analysis</a>.</li></ul>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_20_0200.html">Initialization</a></div>
</div>
</div>

View File

@ -0,0 +1,31 @@
<a name="obs_20_0300"></a><a name="obs_20_0300"></a>
<h1 class="topictitle1">Bucket Management</h1>
<div id="body54167672"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="obs_20_0301.html">Creating a Bucket</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0302.html">Listing Buckets</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0303.html">Deleting a Bucket</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0304.html">Checking Whether a Bucket Exists</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0305.html">Configuring a Bucket ACL</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0311.html">Obtaining a Bucket ACL</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0306.html">Obtaining Bucket Storage Information</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0307.html">Setting a Bucket Quota</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0310.html">Obtaining the Storage Quota of a Bucket</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0308.html">Configuring a Storage Class for a Bucket</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0309.html">Obtaining the Storage Class of a Bucket</a></strong><br>
</li>
</ul>
</div>

2093
docs/obs_3rd_party/c_sdk/obs_20_0301.html vendored Normal file

File diff suppressed because it is too large Load Diff

1987
docs/obs_3rd_party/c_sdk/obs_20_0302.html vendored Normal file

File diff suppressed because it is too large Load Diff

1753
docs/obs_3rd_party/c_sdk/obs_20_0303.html vendored Normal file

File diff suppressed because it is too large Load Diff

1753
docs/obs_3rd_party/c_sdk/obs_20_0304.html vendored Normal file

File diff suppressed because it is too large Load Diff

2733
docs/obs_3rd_party/c_sdk/obs_20_0305.html vendored Normal file

File diff suppressed because it is too large Load Diff

1826
docs/obs_3rd_party/c_sdk/obs_20_0306.html vendored Normal file

File diff suppressed because it is too large Load Diff

1768
docs/obs_3rd_party/c_sdk/obs_20_0307.html vendored Normal file

File diff suppressed because it is too large Load Diff

1795
docs/obs_3rd_party/c_sdk/obs_20_0308.html vendored Normal file

File diff suppressed because it is too large Load Diff

1847
docs/obs_3rd_party/c_sdk/obs_20_0309.html vendored Normal file

File diff suppressed because it is too large Load Diff

1767
docs/obs_3rd_party/c_sdk/obs_20_0310.html vendored Normal file

File diff suppressed because it is too large Load Diff

2265
docs/obs_3rd_party/c_sdk/obs_20_0311.html vendored Normal file

File diff suppressed because it is too large Load Diff

1891
docs/obs_3rd_party/c_sdk/obs_20_0314.html vendored Normal file

File diff suppressed because it is too large Load Diff

2136
docs/obs_3rd_party/c_sdk/obs_20_0315.html vendored Normal file

File diff suppressed because it is too large Load Diff

2338
docs/obs_3rd_party/c_sdk/obs_20_0316.html vendored Normal file

File diff suppressed because it is too large Load Diff

1891
docs/obs_3rd_party/c_sdk/obs_20_0317.html vendored Normal file

File diff suppressed because it is too large Load Diff

2136
docs/obs_3rd_party/c_sdk/obs_20_0318.html vendored Normal file

File diff suppressed because it is too large Load Diff

2338
docs/obs_3rd_party/c_sdk/obs_20_0319.html vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
<a name="obs_20_0400"></a><a name="obs_20_0400"></a>
<h1 class="topictitle1">Object Upload</h1>
<div id="body20951019"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="obs_20_0401.html">Uploading an Object - Streaming</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0402.html">Uploading an Object - File-Based</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0403.html">Creating a Folder</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0407.html">Uploading an Object - Resumable</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="obs_20_0408.html">Uploading an Object - Append</a></strong><br>
</li>
</ul>
</div>

2908
docs/obs_3rd_party/c_sdk/obs_20_0401.html vendored Normal file

File diff suppressed because it is too large Load Diff

2887
docs/obs_3rd_party/c_sdk/obs_20_0402.html vendored Normal file

File diff suppressed because it is too large Load Diff

2821
docs/obs_3rd_party/c_sdk/obs_20_0403.html vendored Normal file

File diff suppressed because it is too large Load Diff

3463
docs/obs_3rd_party/c_sdk/obs_20_0404.html vendored Normal file

File diff suppressed because it is too large Load Diff

2638
docs/obs_3rd_party/c_sdk/obs_20_0405.html vendored Normal file

File diff suppressed because it is too large Load Diff

2867
docs/obs_3rd_party/c_sdk/obs_20_0406.html vendored Normal file

File diff suppressed because it is too large Load Diff

3169
docs/obs_3rd_party/c_sdk/obs_20_0407.html vendored Normal file

File diff suppressed because it is too large Load Diff

2821
docs/obs_3rd_party/c_sdk/obs_20_0408.html vendored Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More