Files
doc-exports/docs/ims/api-ref/en-us_topic_0031615566.html
wanghuijuan738 d5e281fd38 IMS API 20251110 VERSION.
Reviewed-by: Pristromskaia, Margarita <margarita.pristromskaia@t-systems.com>
Co-authored-by: wanghuijuan738 <wanghuijuan738@huawei.com>
Co-committed-by: wanghuijuan738 <wanghuijuan738@huawei.com>
2025-12-12 16:30:47 +00:00

122 lines
12 KiB
HTML

<a name="EN-US_TOPIC_0031615566"></a><a name="EN-US_TOPIC_0031615566"></a>
<h1 class="topictitle1">Uploading an Image (Native OpenStack API)</h1>
<div id="body1465713890378"><div class="section" id="EN-US_TOPIC_0031615566__section11046056154747"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0031615566__p10956056134119">This API is used to upload a local image to the cloud platform. The image to be uploaded must be smaller than 128 GB.</p>
<p id="EN-US_TOPIC_0031615566__p4464523163517">For more information about how to use external files to create images, see sections "Creating a Private Windows Image Using an External Image File" and "Creating a Private Linux Image Using an External Image File" in <em id="EN-US_TOPIC_0031615566__i84235269710411">Image Management Service User Guide</em>.</p>
<p id="EN-US_TOPIC_0031615566__p34229512164319">The following describes how to use this API:</p>
<ol id="EN-US_TOPIC_0031615566__ol42934850155728"><li id="EN-US_TOPIC_0031615566__li50869330155728">Prepare the image to be uploaded. The image can be in QCOW2, VMDK, VHD, RAW, VHDX, QED, VDI, QCOW, ZVHD2, or ZVHD format.</li><li id="EN-US_TOPIC_0031615566__li57474254155728"><a name="EN-US_TOPIC_0031615566__li57474254155728"></a><a name="li57474254155728"></a>Create metadata for the image by performing the operations in <a href="en-us_topic_0031615565.html">Creating Image Metadata (Native OpenStack API)</a>. After the API is invoked successfully, save the image ID.</li><li id="EN-US_TOPIC_0031615566__li17444687173836">Upload the image file with the image ID obtained in <a href="#EN-US_TOPIC_0031615566__li57474254155728">2</a>.</li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0031615566__section66620681154747"><h4 class="sectiontitle">URI</h4><p id="EN-US_TOPIC_0031615566__p3481345716422">PUT /v2/images/{image_id}/file</p>
<div class="p" id="EN-US_TOPIC_0031615566__p5808134861516"><a href="#EN-US_TOPIC_0031615566__table23910047154747">Table 1</a> lists the parameters in the URI.
<div class="tablenoborder"><a name="EN-US_TOPIC_0031615566__table23910047154747"></a><a name="table23910047154747"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0031615566__table23910047154747" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="EN-US_TOPIC_0031615566__row24965460154747"><th align="left" class="cellrowborder" valign="top" width="19.919999999999998%" id="mcps1.3.2.3.2.2.5.1.1"><p id="EN-US_TOPIC_0031615566__p8936346154747">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.919999999999998%" id="mcps1.3.2.3.2.2.5.1.2"><p id="EN-US_TOPIC_0031615566__p4072498116916">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18.98%" id="mcps1.3.2.3.2.2.5.1.3"><p id="EN-US_TOPIC_0031615566__p52755425154747">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="41.18%" id="mcps1.3.2.3.2.2.5.1.4"><p id="EN-US_TOPIC_0031615566__p57477321154747">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0031615566__row25151394154747"><td class="cellrowborder" valign="top" width="19.919999999999998%" headers="mcps1.3.2.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0031615566__p23996995154747">image_id</p>
</td>
<td class="cellrowborder" valign="top" width="19.919999999999998%" headers="mcps1.3.2.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0031615566__p1038913616916">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="18.98%" headers="mcps1.3.2.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0031615566__p64708437154747">String</p>
</td>
<td class="cellrowborder" valign="top" width="41.18%" headers="mcps1.3.2.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0031615566__p54354750154747">Specifies the image ID.</p>
<ul id="EN-US_TOPIC_0031615566__ul2091361694"><li id="EN-US_TOPIC_0031615566__li243224961694"><strong id="EN-US_TOPIC_0031615566__b842352706151612">image_id</strong> is the ID of the image you created by invoking the API for creating image metadata. Image upload may fail if you use other image IDs.</li><li id="EN-US_TOPIC_0031615566__li621310511694">After this API is invoked, you can check the image status with the image ID. When the image status changes to <strong id="EN-US_TOPIC_0031615566__b842352706152426">active</strong>, the image is uploaded successfully.</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="note" id="EN-US_TOPIC_0031615566__note18586131910413"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0031615566__en-us_topic_0121671869_ul1391194815339"><li id="EN-US_TOPIC_0031615566__en-us_topic_0121671869_li591174818336">AK/SK authentication supports API requests with a body not larger than 12 MB. For API requests with a larger body, token authentication is recommended.</li><li id="EN-US_TOPIC_0031615566__en-us_topic_0121671869_li1492910572112">API Gateway checks the time format and compares the request time with the time when API Gateway received the request. If the time difference exceeds 15 minutes, API Gateway will reject the request. So, the local time on the client must be synchronized with the clock server to avoid a large offset in the value of <strong id="EN-US_TOPIC_0031615566__en-us_topic_0121671869_b201061251503">X-Sdk-Date</strong> in the request header.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0031615566__section29704853154747"><h4 class="sectiontitle">Request</h4><ul id="EN-US_TOPIC_0031615566__ul178554583324"><li id="EN-US_TOPIC_0031615566__li1386172311611">Request parameters
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0031615566__table1589154165910" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0031615566__row16589954125913"><th align="left" class="cellrowborder" valign="top" width="16.61%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="EN-US_TOPIC_0031615566__p209573120020">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.06%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="EN-US_TOPIC_0031615566__p18957511209">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.299999999999999%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="EN-US_TOPIC_0031615566__p59571012008"><strong id="EN-US_TOPIC_0031615566__b5086748204848">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="53.03%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="EN-US_TOPIC_0031615566__p89571711901">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0031615566__row15891549597"><td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="EN-US_TOPIC_0031615566__p75891554165913"><em id="EN-US_TOPIC_0031615566__i207861278115">image_file</em></p>
</td>
<td class="cellrowborder" valign="top" width="15.06%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="EN-US_TOPIC_0031615566__p18589654135916">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.299999999999999%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="EN-US_TOPIC_0031615566__p658925419599">file</p>
</td>
<td class="cellrowborder" valign="top" width="53.03%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="EN-US_TOPIC_0031615566__p115891854145911">Specifies the local file to be uploaded.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0031615566__section6761203017178"><h4 class="sectiontitle">Example Request</h4><pre class="screen" id="EN-US_TOPIC_0031615566__screen10805172091812">PUT https://{Endpoint}/v2/images/84ac7f2b-bf19-4efb-86a0-b5be8771b476/file</pre>
<div class="note" id="EN-US_TOPIC_0031615566__note46952046161715"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0031615566__p969713460174">If you use the curl command to call the API, the example request is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0031615566__screen39660571114">curl -i --insecure 'https://IP/v2/images/84ac7f2b-bf19-4efb-86a0-b5be8771b476/file' -X PUT -H "X-Auth-Token: $mytoken" -H "Content-Type:application/octet-stream" -T /mnt/userdisk/images/suse.zvhd</pre>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0031615566__section42338041154747"><h4 class="sectiontitle">Response</h4><ul id="EN-US_TOPIC_0031615566__ul146395711333"><li id="EN-US_TOPIC_0031615566__li16697334191616">Response parameters<p id="EN-US_TOPIC_0031615566__p16934339151619"><a name="EN-US_TOPIC_0031615566__li16697334191616"></a><a name="li16697334191616"></a>None</p>
</li><li id="EN-US_TOPIC_0031615566__li12639207123310">Example response<pre class="codeblock" id="EN-US_TOPIC_0031615566__codeblock3406888294514">HTTP/1.1 204</pre>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0031615566__section61463701154747"><h4 class="sectiontitle">Returned Values</h4><ul id="EN-US_TOPIC_0031615566__ul11464716"><li id="EN-US_TOPIC_0031615566__li36073588">Normal<p id="EN-US_TOPIC_0031615566__p56226836"><a name="EN-US_TOPIC_0031615566__li36073588"></a><a name="li36073588"></a>204</p>
</li><li id="EN-US_TOPIC_0031615566__li36279478">Abnormal
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0031615566__table61689654164325" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0031615566__row43263384164325"><th align="left" class="cellrowborder" valign="top" width="38.080000000000005%" id="mcps1.3.6.2.2.1.1.3.1.1"><p id="EN-US_TOPIC_0031615566__p14673233164325">Returned Value</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="61.919999999999995%" id="mcps1.3.6.2.2.1.1.3.1.2"><p id="EN-US_TOPIC_0031615566__p47681194164325"><strong id="EN-US_TOPIC_0031615566__b53324949161548">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0031615566__row36971467164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.2.2.1.1.3.1.1 "><p id="EN-US_TOPIC_0031615566__p41898845164325">400 Bad Request</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.2.2.1.1.3.1.2 "><p id="EN-US_TOPIC_0031615566__p38363271164325">Request error. For details, see <a href="en-us_topic_0022473689.html">Error Codes</a>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0031615566__row20417266164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.2.2.1.1.3.1.1 "><p id="EN-US_TOPIC_0031615566__p43185862164325">401 Unauthorized</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.2.2.1.1.3.1.2 "><p id="EN-US_TOPIC_0031615566__p8393897164325">Authentication failed.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0031615566__row8436217164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.2.2.1.1.3.1.1 "><p id="EN-US_TOPIC_0031615566__p12244985164325">403 Forbidden</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.2.2.1.1.3.1.2 "><p id="EN-US_TOPIC_0031615566__p52319709164325">You do not have the rights to perform the operation.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0031615566__row1115336164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.2.2.1.1.3.1.1 "><p id="EN-US_TOPIC_0031615566__p23233406164325">404 Not Found</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.2.2.1.1.3.1.2 "><p id="EN-US_TOPIC_0031615566__p2857740164325">The requested resource was not found.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0031615566__row33911260174644"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.2.2.1.1.3.1.1 "><p id="EN-US_TOPIC_0031615566__p33585825174654">409 Conflict</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.2.2.1.1.3.1.2 "><p id="EN-US_TOPIC_0031615566__p36097324174654">Request conflict.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0031615566__row60371567174640"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.2.2.1.1.3.1.1 "><p id="EN-US_TOPIC_0031615566__p8274976174654">500 System Error</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.2.2.1.1.3.1.2 "><p id="EN-US_TOPIC_0031615566__p66293315174654">System error.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0122410334.html">Image (Native OpenStack APIs)</a></div>
</div>
</div>