Send a file with webpy and urllib2
I need to send a file to another server using oauth and webpy. For now I'll ignore the oauth part as sending the file itself is already a challenge.
Here's my partial code:
class create_video:
def POST(self):
x = web.input(video_original={})
开发者_如何学GoAt this point I want to send the file over the network using urllib2. Note that I also have other parameters to send.
UPDATE
considering that I want to send these parameters:
params = {
'title': x['title'],
'video_original': x['video_original'].file
}
How do I use urllib2 (or anything else) to send them to a given url?
P.S. I've tried to use the poster module but I don't know how to send generic parameters along with the file.
You're coming from here, I guess.
The POST
method defines how to receive data via POST requests, rather than send any data. In your code, the data from an incoming POST request is saved in x
. How do you want to proceed now? If you want to send the data to another url, use urllib(2) as described here.
精彩评论