[英]How can I Troubleshoot the Google Cloudstorage Client?
Given the sample code: 给定示例代码:
import cloudstorage
from django.shortcuts import render
def list_files(request):
file_list = []
try:
bucket_name = my_bucket
gcs_list_obj = cloudstorage.listbucket('/' + bucket_name, delimiter="/")
for item in gcs_list_obj:
file_list.append(item)
except Exception, e:
raise e
return render(request, 'default.htm', {'file_list': file_list,
'bucket_name': bucket_name})
The expectation would be to see a populated array of iterated objects from cloudstorage.listbucket Instead Django throws an InternalError
with the message 5:
期望是从cloudstorage.listbucket看到一个填充的迭代对象数组,取而代之的是Django抛出信息
5:
引发InternalError
5:
What are the common steps for troubleshooting Storage buckets in django? 在django中对存储分区进行故障排除的常见步骤是什么?
Did you want to add to file_list GCSFileStat objects (and are you handling it correctly in the template) or just the filenames. 您是否要添加到file_list GCSFileStat对象(并且是否正在模板中正确处理它)或仅添加文件名。
If the latter than you can add item.filename instead. 如果是后者,则可以添加item.filename代替。
After much frustration, it seems there the issue was related to my project NOT having a default bucket . 经过无奈的尝试之后,问题似乎与我的项目没有默认存储桶有关 。
Navigating to: https://console.developers.google.com/storage/browser/YOUR_PROJECT.appspot.com/
导航至:
https://console.developers.google.com/storage/browser/YOUR_PROJECT.appspot.com/
: https://console.developers.google.com/storage/browser/YOUR_PROJECT.appspot.com/
Then uploading a few files / folders seems to have resolved the issue, and the sample code works as expected. 然后上传一些文件/文件夹似乎已解决了该问题,并且示例代码按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.