开发者

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={})
开发者_如何学Go

At 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜