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

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


  • To: "xen-api@xxxxxxxxxxxxx" <xen-api@xxxxxxxxxxxxx>
  • From: "Agyeman B. Danso Jr." <ADanso@xxxxxxxxxxxxxxxx>
  • Date: Fri, 18 Oct 2013 16:16:45 +0000
  • Accept-language: en-US
  • Delivery-date: Fri, 18 Oct 2013 20:50:06 +0000
  • List-id: User and development list for XCP and XAPI <xen-api.lists.xen.org>
  • Thread-index: Ac7JB2xSsNNyuHXlRLSnpNPYtNKO7wDFeYiw
  • Thread-topic: 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®.