本文介绍了Django collecstatic boto破碎管大文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将静态文件上传到我的S3桶与收藏,但我得到一个破坏的管道错误与一个700k的JavaScript文件,这是错误

I am trying to upload the static files to my S3 bucket with collectstatic but i'm getting a broken pipe error with a 700k javascript file, this is the error

Copying '/Users/wedonia/work/asociados/server/asociados/apps/panel/static/panel/js/js.min.js'
    Traceback (most recent call last):
      File "manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
        utility.execute()
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
        output = self.handle(*args, **options)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
        return self.handle_noargs(**options)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 173, in handle_noargs
        collected = self.collect()
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 112, in collect
        handler(path, prefixed_path, storage)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 317, in copy_file
        self.storage.save(prefixed_path, source_file)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/django/core/files/storage.py", line 49, in save
        name = self._save(name, content)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/storages/backends/s3boto.py", line 392, in _save
        self._save_content(key, content, headers=headers)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/storages/backends/s3boto.py", line 403, in _save_content
        rewind=True, **kwargs)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/s3/key.py", line 1291, in set_contents_from_file
        chunked_transfer=chunked_transfer, size=size)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/s3/key.py", line 748, in send_file
        chunked_transfer=chunked_transfer, size=size)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/s3/key.py", line 949, in _send_file_internal
        query_args=query_args
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/s3/connection.py", line 664, in make_request
        retry_handler=retry_handler
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/connection.py", line 1068, in make_request
        retry_handler=retry_handler)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/connection.py", line 939, in _mexe
        request.body, request.headers)
      File "/Users/wedonia/work/asociados/server/envs/asociados/lib/python2.7/site-packages/boto/s3/key.py", line 842, in sender
        http_conn.send(chunk)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 805, in send
        self.sock.sendall(data)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 229, in sendall
        v = self.send(data[count:])
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 198, in send
        v = self._sslobj.write(data)
    socket.error: [Errno 32] Broken pipe

我的设置如下

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 's3utils.StaticRootS3BotoStorage'
AWS_S3_ACCESS_KEY_ID = ''
AWS_S3_SECRET_ACCESS_KEY = ''
AWS_STORAGE_BUCKET_NAME = 'asociados.static'

我尝试更改互联网连接并获得相同的结果

I tried change the internet connection and get the same result

我尝试使用一个200k的文件,得到相同的结果

I tried with a 200k file and got the same result

有人有同样的问题?

推荐答案

设置 AWS_S3_HOST settings.py 到您正确的区域,例如 s3-eu-west-1.amazonaws.com

Set AWS_S3_HOST in settings.py to your correct region, e.g. s3-eu-west-1.amazonaws.com.

AWS_S3_HOST =s3 -eu-west-1.amazonaws.com

查看最新的Amazon 以供参考。

See the latest Amazon list for complete reference.

此也很有帮助。

这篇关于Django collecstatic boto破碎管大文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 14:02