Uploading an ISO-format media image to a catalog creates a Media object and a corresponding CatalogItem object.
vCloud Director supports using the vCloud API to upload media images to a catalog.
The workflow for uploading media images is similar to the one shown in Upload an OVF Package to Create a vApp Template.
Verify that the following conditions are met:
1 | Find the add link for media in the target catalog This link has the following form: <Link rel="add" type="application/vnd.vmware.vcloud.media+xml" href="https://vcloud.example.com/api/catalog/32/action/upload" /> |
2 | POST an action/upload request to the URL shown in Step 1 The request body is a Media element. See the request portion of Example: Upload a Media Image . The server uses this information to create a CatalogItem and corresponding Media object, then returns the CatalogItem in its response. See the response portion of Example: Upload a Media Image . |
3 | Use the URL in the Entity element of the CatalogItem to retrieve the Media object. The Media element includes a File element that contains an upload:default URL. |
4 | PUT the media file contents to the upload:default link in the response. The procedure is the same as the one shown in Uploading Referenced Files. |
There are two steps to uploading a media file. The first step is to make an action/upload request to the catalog. The request body is a Media element that specifies the size of the ISO file and the name that you want to apply to the created Media object. The imageType attribute is optional, and must be set to a value of iso if you supply it.
POST https://vcloud.example.com/api/catalog/32/action/upload Content-Type: application/vnd.vmware.vcloud.media+xml ... <?xml version="1.0" encoding="UTF-8"?> <Media xmlns="http://www.vmware.com/vcloud/v1.5" name="database.iso" size="51242131" imageType="iso"> <Description>ISO database image</Description> </Media>
201 Created Content-Type: application/vnd.vmware.vcloud.catalogItem+xml ... <CatalogItem xmlns="http://www.vmware.com/vcloud/v1.5" name="database.iso" id="urn:vcloud:catalogitem:221" href="https://vcloud.example.com/api/catalogItem/221" ... > <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloud.example.com/api/catalog/32" /> <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloud.example.com/api/catalogItem/221/metadata" /> <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloud.example.com/api/catalogItem/221" /> <Link rel="remove" href="https://vcloud.example.com/api/catalogItem/221" /> <Description>Approved template for public FTP sites</Description> <Entity type="application/vnd.vmware.vcloud.media+xml" name="database.iso" href="https://vcloud.example.com/api/media/254" /> </CatalogItem>
Examine the response to the action/upload request, then make a GET request to the URL in the Entity element of the CatalogItem to retrieve the Media object.
GET https://vcloud.example.com/api/media/254
The Media object includes an upload URL for the media file itself.
<Media ... > ... <Files> <File name="database.iso" bytesTransferred="0"> <Link rel="upload:default" href="https://vcloud.example.com/transfer/.../database.iso" /> </File> </Files> ... </Media>
PUT the media file contents to the upload:default link in the response. The procedure is the same as the one shown in Uploading Referenced Files.
The upload URL remains valid while a transfer session is in progress, and for a maximum of 60 minutes of transfer session idle time. A system administrator can change this default value. See Retrieve or Update System Settings.