我正在尝试使用我的GAE python应用程序获取s3(使用boto)设置来存储用户上传的图像.目前我收到以下错误:
File "/Users/phyzikz/project/boto/s3/key.py", line 936, in set_contents_from_file spos = fp.tell()
AttributeError: 'str' object has no attribute 'tell'
我不知道为什么会发生这种情况 – 上传的文件应该是png.这是上传的代码:
class Settings(Handler):
def get(self):
self.render('settings.html')
def post(self):
image = self.request.get('image')
if image:
connection = S3Connection('','')
bucket = connection.create_bucket('')
k = Key(bucket)
k.key = '/pictures/users/'+ str(self.user.key().id())
k.set_contents_from_file(image)
如果它有帮助,在调试时,当用set_contents_from_string(‘some string’)替换set_contents_from_file(image)时,它工作得非常好.我一定很遗憾.这是html:
免责声明:我是python和SO的新手(这是我的第一个问题!)如果有必要,任何改进问题措辞的编辑都将受到赞赏.