5.1

Table Of Contents
Procedure
1 Find the add link for media in the target vDC.
This link has the following form:
<Link
rel="add"
type="application/vnd.vmware.vcloud.media+xml"
href="https://vcloud.example.com/api/vdc/5/media" />
2 POST a media request to the server.
The request body is a Media element that includes information about the virtual media item to upload. See
the request portion of “Example: Upload a Media Image,” on page 70.
The server uses this information to create a Media object, then returns a representation of the object that
contains an upload URL. See the response portion of “Example: Upload a Media Image,” on page 70.
3 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,” on page 63.
Example: Upload a Media Image
Request:
POST https://vcloud.example.com/api/vdc/5/media
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>
In addition to the File element that contains the upload:default URL, the response includes an Owner element
and several Link elements that the server creates.
Response:
Content-Type: application/vnd.vmware.vcloud.media+xml
201 Created
...
<Media
xmlns="http://www.vmware.com/vcloud/v1.5"
size="3121215488"
imageType="iso"
status="0"
name="database.iso"
id="urn:vcloud:media:254"
type="application/vnd.vmware.vcloud.media+xml"
href="https://vcloud.example.com/api/media/254" ... >
<Link
rel="up"
type="application/vnd.vmware.vcloud.vdc+xml"
href="https://vcloud.example.com/api/vdc/5" />
<Link
vCloud API Programming Guide
70 VMware, Inc.