我正在尝试使用shopify python库创建资产,但我收到了ResourceNotFound异常。以下是我的代码片段。
asset = shopify.Asset(dict(key=self.key, theme_id=theme_id))
asset.attach(image.read())
asset.save()
这是异常的堆栈跟踪
Traceback:
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/core/handlers/base.py" in get_response
105. response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/mezzanine/pages/middleware.py" in process_view
45. return view_func(request, *view_args, **view_kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/base.py" in view
48. return self.dispatch(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/contrib/auth/decorators.py" in _wrapped_view
20. return view_func(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_app/decorators.py" in wrapper
10. return func(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_galleries/views.py" in dispatch
81. return super(UploadImageView, self).dispatch(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/base.py" in dispatch
69. return handler(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/edit.py" in post
138. return self.form_valid(form)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_galleries/views.py" in form_valid
96. image.store_image(image_field)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_galleries/models.py" in store_image
62. asset.save()
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/shopify/base.py" in save
151. return super(ShopifyResource, self).save()
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/activeresource.py" in save
775. data=self.to_xml())
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/connection.py" in put
351. return self._open('PUT', path, headers=headers, data=data)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/shopify/base.py" in _open
18. self.response = super(ShopifyConnection, self)._open(*args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/connection.py" in _open
287. http_response = self._handle_error(err)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/connection.py" in _handle_error
407. raise ResourceNotFound(err)
Exception Type: ResourceNotFound at /galleries/upload/
Exception Value: Not Found: https://sawayn-and-sons9677.myshopify.com/admin/themes/3422503/assets.xml
关于为什么会发生这种情况的任何想法?
答案 0 :(得分:4)
我在日志中找到了您的请求,并注意到您使用的密钥是“14e2ccbe-601e-4bd8-bb61-726c221b53cf-6..png”。
资产需要位于合适的目录中。
在您的情况下,您可能需要key = "assets/14e2ccbe-601e-4bd8-bb61-726c221b53cf-6.png"
抱歉错误消息无效。 404指的是找不到密钥的目录。