我正试图用<代码>多部分_encode上载一个文件,以实现<代码>MIME程序。 然而,我遇到了以下错误:<代码>。 AttributeError: multipart_yielder instance has no Depende __len__ 。 下面是我的做法,我确实赞赏大家能向我提出一些建议。
url = "https://pi-user-files.s3-external-1.amazonaws.com/"
post_data = {}
#data is a dict
post_data[ AWSAccessKeyId ]=(data[ ticket ][ AWSAccessKeyId ])
post_data[ success_action_redirect ]=(data[ ticket ][ success_action_redirect ])
post_data[ acl ]=(data[ ticket ][ acl ])
post_data[ key ]=(data[ ticket ][ key ])
post_data[ signature ]=(data[ ticket ][ signature ])
post_data[ policy ]=(data[ ticket ][ policy ])
post_data[ Content-Type ]=(data[ ticket ][ Content-Type ])
#I would like to upload a text file "new 2"
post_data[ file ]=open("new 2.txt", "rb")
datagen, headers = multipart_encode(post_data)
request2 = urllib2.Request(url, datagen, headers)
result = urllib2.urlopen(request2)