一段时间后,将 Django 的 collectstatic 与 boto S3 一起使用会抛出 "Error 32: Broken Pipe"

Using Django's collectstatic with boto S3 throws "Error 32: Broken Pipe" after a while

我将 boto 与 S3 结合使用来存储我的 Django 站点的静态文件。当使用 collectstatic 命令时,它会完美地上传大量文件,然后停止在一个文件并抛出 "Error 32: Broken Pipe." 当我再次尝试 运行 命令时,它会跳过它要处理的文件已经上传并从它停止的文件开始,然后在没有上传任何新内容的情况下抛出相同的错误。

关键好像是指定哪个AWS Endpoint your bucket is located in. I tried doing this a bunch of different ways, but the solution that finally worked for me was to create a config file for boto as specified in the documentation.

以下是我在 ~/.boto 创建的配置文件的内容:

[Credentials]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[s3]
host=s3-us-west-2.amazonaws.com

BenWurth 的回答很好,但如果你像我一样不想添加配置文件,你也可以使用 django-storages 维护得更好的表弟 "django-storages-redux" 并添加一个额外的环境变量至 settings.py

pip uninstall django-storages (if you have this installed)
pip install django-storages-redux

然后在 settings.py

AWS_S3_HOST = 'YOUR-AWS-ENDPOINT' #in my case 's3-us-west-2.amazonaws.com'

那应该一切都好。

老问题,但为了轻松解决这个问题,我只是将环境变量 "AWS_DEFAULT_REGION" 添加到我正在使用的区域(例如 "ap-southeast-2")。这在本地 (windows) 和 AWS EB

中有效

我也只有 jquery.js 有问题,可能是因为它太大了,就像@Kyle Falconer 提到的那样。就我而言,这与地区无关。我 "solved" 通过将文件本地复制到需要它的 S3 存储桶中。