Skip navigation
VMware
Up to Discussions in VMware vCloud™ API

Developer: VMware vCloud™ API

Open. Extensible. Pure Virtual.
 

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
294 Views 3 Replies Last post: May 31, 2011 12:41 PM by geoffaviarc RSS
geoffaviarc Novice 18 posts since
Sep 20, 2010
Currently Being Moderated

May 30, 2011 9:43 PM

Uploading Media via vcloud-java-sdk.  Potential SDK bug?

I cannot seem to upload from an input stream via the vcloud-java-sdk.

 

I get a root cause exception in

Caused by: com.vmware.vcloud.sdk.VCloudException: No file(s) to upload
at com.vmware.vcloud.sdk.Media.uploadFile(Media.java:219)
I am using code like so...
MediaType mediaType = new MediaType();
mediaType.setName(filename);
mediaType.setDescription(description);
mediaType.setImageType(ImageType.ISO);
mediaType.setSize(size)
Media media = vdc.createMedia(mediaType);
mediaType = media.getResource();
media = Media.getMediaByReference(client, media.getReference());
media.uploadFile(filename, inputStream, size);
...
the XML that the rest interface is returning is puzzling.
    <Description>some description</Description>
</Media>
31/05/2011 4:39:53 PM com.vmware.vcloud.sdk.RestUtil post
INFO: POST Request Content-Type: application/vnd.vmware.vcloud.media+xml
31/05/2011 4:39:53 PM com.vmware.vcloud.sdk.RestUtil post
INFO: POST Request charset: null
31/05/2011 4:39:54 PM com.vmware.vcloud.sdk.RestUtil post
INFO: status Code: 201
31/05/2011 4:39:54 PM com.vmware.vcloud.sdk.RestUtil post
INFO: Status Line: HTTP/1.1 201 Created
31/05/2011 4:39:54 PM com.vmware.vcloud.sdk.RestUtil post
INFO: Status: Created
31/05/2011 4:39:54 PM com.vmware.vcloud.sdk.RestUtil post
INFO: Response: <?xml version="1.0" encoding="UTF-8"?>
<Media xmlns="http://www.vmware.com/vcloud/v1" size="345345345" imageType="iso" status="0" name="install48.iso" type="application/vnd.vmware.vcloud.media+xml" href="https://10.0.11.31/api/v1.0/media/51961368" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://10.0.11.31/api/v1.0/schema/master.xsd">
    <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://10.0.11.31/api/v1.0/vdc/215376122"/>
    <Link rel="remove" href="https://10.0.11.31/api/v1.0/media/51961368"/>
    <Link rel="edit" type="application/vnd.vmware.vcloud.media+xml" href="https://10.0.11.31/api/v1.0/media/51961368"/>
    <Description>some description</Description>
    <Files>
        <File size="345345345" bytesTransferred="0" name="file">
            <Link rel="upload:default" href="https://10.0.11.31:443/transfer/d2664ecc-3e2f-4113-9692-7c6624e4783d/file"/>
        </File>
    </Files>
</Media>
the snippet that worries me is the filename in the file element.
<File size="345345345" bytesTransferred="0" name="file">
            <Link rel="upload:default" href="https://10.0.11.31:443/transfer/d2664ecc-3e2f-4113-9692-7c6624e4783d/file"/>
</File>
it appears to be ignoring my file name that is in the original request

 

 

i've tried resetting the file in the file list to the correct name but if I fetch the media again from vcloud the response is like so...

 

INFO: Response: <?xml version="1.0" encoding="UTF-8"?>
<Media xmlns="http://www.vmware.com/vcloud/v1" size="345345345" imageType="iso" status="0" name="install48.iso" type="application/vnd.vmware.vcloud.media+xml" href="https://10.0.11.31/api/v1.0/media/51961368" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://10.0.11.31/api/v1.0/schema/master.xsd">
    <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://10.0.11.31/api/v1.0/vdc/215376122"/>
    <Link rel="remove" href="https://10.0.11.31/api/v1.0/media/51961368"/>
    <Link rel="edit" type="application/vnd.vmware.vcloud.media+xml" href="https://10.0.11.31/api/v1.0/media/51961368"/>
    <Description>some description</Description>
    <Files>
        <File size="345345345" bytesTransferred="0" name="file">
            <Link rel="upload:default" href="https://10.0.11.31:443/transfer/d2664ecc-3e2f-4113-9692-7c6624e4783d/file"/>
        </File>
    </Files>
</Media>
Is something broken?

rkamal Expert 255 posts since
Jan 28, 2009
Currently Being Moderated
1. May 30, 2011 10:30 PM in response to: geoffaviarc
Re: Uploading Media via vcloud-java-sdk.  Potential SDK bug?

Hi,

 

mediaType.setName(mediaName);

-- This refers to the name of the media and not the file name.

 

media.uploadFile(fileName, inputStream, size);
-- The filename for this method should be from Media -> getUploadFileNames().
Regards,
Rajesh Kamal.
rkamal Expert 255 posts since
Jan 28, 2009
Currently Being Moderated
3. May 31, 2011 12:46 PM in response to: geoffaviarc
Re: Uploading Media via vcloud-java-sdk.  Potential SDK bug?

I think it is a documentation bug.

 

Regards,

Rajesh Kamal.

Bookmarked By (0)

Communities