1
>>> import boto
>>> s3 = boto.connect_s3('<access_key>', '<secret_key>')
>>> bucket = s3.lookup('donebox-static')
>>> key = bucket.new_key('testkey')
>>> key.set_contents_from_string('This is a test')
>>> key.exists()
>>> key.delete()
雖然刪除,我得到以下錯誤。我正在使用Linux機器,但我可以從Windows機器上刪除文件。 錯誤是:我想從S3存儲桶中使用python刪除文件,但我無法刪除文件
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/boto-2.48.0-py2.7.egg/boto/s3/key.py", line 558, in delete
headers=headers)
File "/usr/lib/python2.7/site-packages/boto-2.48.0-py2.7.egg/boto/s3/bucket.py", line 762, in delete_key
query_args_l=None)
File "/usr/lib/python2.7/site-packages/boto-2.48.0-py2.7.egg/boto/s3/bucket.py", line 781, in _delete_key_internal
response.reason, body)
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>6CF28CE4F8227FAE</RequestId><HostId>mrS5DIDHvXgweWSlwmQYVE0H05jsnepXd+3PiMqHcjXhWPkfo8ibeWA9rBcm7fKkdAO2f/fUTjo=</HostId></Error
>
相同的代碼也適用於我,當我嘗試與不同區域的不同桶,不知道爲什麼會發生這種情況。 –