Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to upload a file to a remote server using python
    primarykey
    data
    text
    <p>I need to upload a file to a remote location using python - wsgi. Remote location means not the server which host the python application, it is a different server. </p> <p>I tried upload a file to the server which exactly the application host. And it is succeeded.</p> <p>using following code,</p> <pre><code> post = cgi.FieldStorage(fp=environ['wsgi.input'],environ=environ,keep_blank_values=True) self.msg = str(post) try: fileitem = post['Filedata'] if fileitem.file: filename = fileitem.filename.decode('utf8').replace('\\','/').split('/')[-1].strip() if not filename: raise Exception('No valid filename specified') file_path = os.path.join(self.uploadpath, filename) # Using with makes Python automatically close the file for you counter = 0 with open(file_path, 'wb') as output_file: while 1: data = fileitem.file.read(1024) # End of file if not data: break output_file.write(data) counter += 1 if counter == 100: counter = 0 self.msg = "Uploaded Successfully !!!! " except: pass </code></pre> <p>But this is for the the local location which the python application hosted. I search about Google how to upload a file to remote location in python. But I can't find a proper solution for that. Some are suggested to do scp from python code.</p> <p>more..</p> <p>Let say there are two servers called A and B. My python-wsgi application for file uploading is hosted on server A. In the python-wsgi application there is a web form to select the file by user when user click upload then that file need to uploaded to server B (known location)</p> <p>Any one knows a way or library to upload a file to remote location using python? </p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload