【发布时间】:2016-08-05 20:15:35
【问题描述】:
我在 Python 3 上通过 django-storages boto storage 使用 S3 文件存储。当我尝试上传文件时,出现以下错误:
boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>BadDigest</Code>
<Message>The Content-MD5 you specified did not match what we received.</Message>
...
我要保存的文件是一个通过请求下载的文件。它的要点是:
import requests
from django.core.files.base import ContentFile
response = requests.get("http://example.com/some_file.pdf")
document_contents = ContentFile(response.text)
my_model.save("filename", document_contents)
我做错了什么?
【问题讨论】:
标签: python django python-3.x amazon-s3 python-django-storages