Uploading an ISO-format media image to a catalog creates a Media object and a corresponding CatalogItem object.
Prerequisites
Verify that the following conditions are met:
- You have a media image to upload.
- You are logged in as a user who has permission to upload media images.
- You know the URL of the target catalog that will receive the upload. Retrieve the XML representation of your organization to see a list of the catalogs that it contains.
Procedure
Example: Upload a Media Image
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.