Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessDeny Error #30

Open
Muzijiajian opened this issue Aug 30, 2018 · 0 comments
Open

AccessDeny Error #30

Muzijiajian opened this issue Aug 30, 2018 · 0 comments

Comments

@Muzijiajian
Copy link

博主你好,我直接在views里面定义相关的access_id & access_key进行验证oss,控制台输出可以返回一个oss的object,但是想去遍历这个的时候出现报错,如下:
System check identified no issues (0 silenced).
August 30, 2018 - 06:01:08
Django version 1.11, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
<oss2.api.Bucket object at 0x7f1c675b7d90>
Internal Server Error: /mark_index/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/lord/imooc/mysite/marking/views.py", line 26, in index
for obj in oss2.ObjectIterator(bucket, delimiter='/'):
File "/usr/local/lib/python2.7/dist-packages/oss2/iterators.py", line 43, in next
return self.next()
File "/usr/local/lib/python2.7/dist-packages/oss2/iterators.py", line 40, in next
self.fetch_with_retry()
File "/usr/local/lib/python2.7/dist-packages/oss2/iterators.py", line 48, in fetch_with_retry
self.is_truncated, self.next_marker = self._fetch()
File "/usr/local/lib/python2.7/dist-packages/oss2/iterators.py", line 108, in _fetch
max_keys=self.max_keys)
File "/usr/local/lib/python2.7/dist-packages/oss2/api.py", line 331, in list_objects
'encoding-type': 'url'})
File "/usr/local/lib/python2.7/dist-packages/oss2/api.py", line 1128, in __do_object
return self._do(method, self.bucket_name, key, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oss2/api.py", line 154, in _do
raise exceptions.make_exception(resp)
AccessDenied: {'status': 403, 'request-id': '5B87882C95F081E9CA6611B4', 'details': {'HostId': 'uncertain.oss-cn-beijing.aliyuncs.com', 'Message': 'OSS authentication requires a valid Date.', 'Code': 'AccessDenied', 'RequestId': '5B87882C95F081E9CA6611B4'}}
ERROR:django.request:Internal Server Error: /mark_index/

view中代码如下:
def index(request):
# 遍历oss云端bucket
auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
bucket = oss2.Bucket(auth, END_POINT, 'uncertain')
print bucket
for obj in oss2.ObjectIterator(bucket, delimiter='/'):
print('Processing')
welcom = u"这是首页!!"
return render(request, 'marking/index.html', {'welcom': welcom})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant