我已经下载了Django的包,下面你的描述Azure的SDK。我编写了一个样本来重现此问题,但它在我身边正常工作。以下是我所做的步骤: 设置环境:Python 2.7和Azure SDK(0.10.0)。
1.Trying使用Django的Azure的存储 这是非常令人沮丧的,我并没有将其导入到我的项目成功,因为这是我第一次用它。通常,我利用Azure Python SDK directly。这次我在我的项目中复制了storage.py作为AzureStorage
类。
#need import django contentfile type
from django.core.files.base import ContentFile
#import the AzureStorage Class form my project
from DjangoWP.AzureStorage import AzureStorage
# my local image path
file_path="local.png";
# my Azure storage blob file
def djangorplugin():
azurestorage=AzureStorage(myaccount, mykey,"mycontainer")
stream=open(file_path, 'rb')
data = stream.read()
#need convert file to ContentFile
azurestorage.save("Testfile1.png",ContentFile(data))
2.You很多想知道如何使用Azure的SDK的Python直接,下面的代码片段供大家参考:
from azure.storage.blobservice import BlobService
#my local image path
file_path="local.png";
def upload():
blob_service = BlobService(account_name=myaccount, account_key=mykey)
stream=open(file_path, 'rb')
data = stream.read()
blob_service.put_blob("mycontainer","local.png",data,"BlockBlob")
如果您有任何疑虑,请随时让我们知道。
你能分享你的代码吗?我倾向于认为该错误与内容类型的请求标题有关。 –
代码可以在上面链接的django-azure-storage repo中找到。 – rawbeans