我尝试使用s3.Bucket('myfirstbucket').upload_file('myfile.json', 'myfile.json')
将桌面上的json文件上传到S3存储桶。我用了代码: -
s3.Bucket('myfirstbucket').put_object(Key='myfile.json',Body=data)
和
<footer class="footer">
<div class="summary">
<table id="nodecor">
<tr>
<th>Total Calories: </th>
<th>Carbs: </th>
<th>Fat: </th>
<th>Protein: </th>
</tr>
<tr>
<td class="bigtext"><span id="total">0</span> G</td>
<td class="bigtext"><span id="totalCarbs">0</span> G</td>
<td class="bigtext"><span id="totalFats">0</span> G</td>
<td class="bigtext"><span id="totalProteins">0</span> G</td>
</tr>
</table>
</div>
</footer>
但每次它都会出错 -
“目录中找不到此类文件”
我无法弄清楚这个错误的原因。请指导
答案 0 :(得分:0)
我认为你应该阅读这份文件。这是与存储桶建立正确连接的良好开端
from boto.s3.key import Key
from boto.s3.connection import S3Connection
AWS__BUCKET = "your-buckett"
AWS_ACCESS_KEY_ID = "your key id"
AWS_SECRET_ACCESS_KEY = "your secret key"
from boto.s3.connection import S3Connection
conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
my_bucket = conn.get_bucket(AWS_BUCKET)
现在您可以发送一些数据
k = Key(b)
k.key = 'myfile.json'
k.set_contents_from_filename('myfile.json')
此处有更多信息:http://boto.cloudhackers.com/en/latest/s3_tut.html#storing-data