[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-API] Help with Uploading a file to XenSever XCP


  • To: "Agyeman B. Danso Jr." <ADanso@xxxxxxxxxxxxxxxx>, "xen-api@xxxxxxxxxxxxx" <xen-api@xxxxxxxxxxxxx>
  • From: Bob Ball <bob.ball@xxxxxxxxxx>
  • Date: Sat, 19 Oct 2013 07:46:44 +0000
  • Accept-language: en-GB, en-US
  • Delivery-date: Sat, 19 Oct 2013 07:47:05 +0000
  • List-id: User and development list for XCP and XAPI <xen-api.lists.xen.org>
  • Thread-index: Ac7JB2xSsNNyuHXlRLSnpNPYtNKO7wDFeYiwACBlNro=
  • Thread-topic: Help with Uploading a file to XenSever XCP

I'm not sure it's possible to do this - the XAPI web interface is very simple - although I'll let someone else who knows for certain to comment too.

I just wanted to highlight that the example from the blog post was about creating a XenAPI plugin that allows you to upload something already existing on the XenServer to an external service - in this case Glance.

The intention of this plugin is to take an image already existing on XenServer and push it up to Glance, or to take an image on Glance and pull it down.  It is not possible to use this plugin to upload an image via the XAPI www interface.

Bob


From: xen-api-bounces@xxxxxxxxxxxxx [xen-api-bounces@xxxxxxxxxxxxx] on behalf of Agyeman B. Danso Jr. [ADanso@xxxxxxxxxxxxxxxx]
Sent: 18 October 2013 17:16
To: xen-api@xxxxxxxxxxxxx
Subject: [Xen-API] FW: Help with Uploading a file to XenSever XCP

Good afternoon team,

 

My team and I are working on a way to have users upload a txt, jpg, or pdf, like files onto our XenServer XCP. I came across your host plugin write up http://blogs.citrix.com/2012/08/17/hello-xen-api-host-plugin/ , and saw that you mentioned something about uploading images.

 

Will it be possible for you to assist me? We have a simple html file in the /opt/xensource/www,

We then added a form, to allow users who browse to the ip address of the sever to upload a file to it.

 

___________________________________________________

Index.html

<form enctype="multipart/form-data" action="" name="save_file2.py" method="post" style="color:#454545;font-size:16px;font-weight:normal;text-align:left;margin:10px;">

Choose a file to upload: <input type="file" name="file"><br />

<input type="submit" value="Upload"></p>

</form>

___________________________________________________

Save_file.py

#!/usr/bin/env python

import cgi, os

import cgitb; cgitb.enable()

 

try: # Windows needs stdio set for binary mode.

    import msvcrt

    msvcrt.setmode (0, os.O_BINARY) # stdin  = 0

    msvcrt.setmode (1, os.O_BINARY) # stdout = 1

except ImportError:

    pass

 

form = cgi.FieldStorage()

 

# A nested FieldStorage instance holds the file

fileitem = form['file']

 

# Test if the file was uploaded

if fileitem.filename:

  

   # strip leading path from file name to avoid directory traversal attacks

   fn = os.path.basename(fileitem.filename)

   open('files/' + fn, 'wb').write(fileitem.file.read())

   message = 'The file "' + fn + '" was uploaded successfully'

  

else:

   message = 'No file was uploaded'

  

print """\

Content-Type: text/html\n

<html><body>

<p>%s</p>

</body></html>

""" % (message,)

___________________________________________________

 

Unfortunately, when I test out the html, it returns the below error:

 

 

Can you please help me to understand what is happening, and maybe I can finally get this upload process to work properly.

 

 

Thank you,

Agyeman B. Danso Jr.

Security Engineer

infoLock Technologies

877.610.5625 x253 - direct

ADanso@xxxxxxxxxxxxxxxx

 

_______________________________________________
Xen-api mailing list
Xen-api@xxxxxxxxxxxxx
http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.