生产中的S3上传失败(Python)

时间:2017-11-16 23:49:37

标签: python django amazon-web-services amazon-s3 boto3

我试图在我的Django应用程序中将XML文件上传到S3。

我尝试过tinys3,boto3和boto原味。

tinys3就像localhost中的魅力一样,但如果我在使用Elastic Beanstalk加载文件时甚至导入文件,我会得到一个错误,就像我从boto3那样得到的错误(除了boto3让我获取启动服务器并从客户端启动xml上传:

invalid syntax (_base.py, line 381)

导入tinys3后,我收到此错误(同样,仅在弹性beanstalk上):

[Fri Nov 17 00:51:28.918531 2017] [:error] [pid 32767]   File "/opt/python/current/app/user_package/views.py", line 22, in <module>
[Fri Nov 17 00:51:28.918533 2017] [:error] [pid 32767]     import tinys3
[Fri Nov 17 00:51:28.918534 2017] [:error] [pid 32767]   File "/opt/python/run/venv/lib/python3.4/site-packages/tinys3/__init__.py", line 4, in <module>
[Fri Nov 17 00:51:28.918536 2017] [:error] [pid 32767]     from .pool import Pool
[Fri Nov 17 00:51:28.918537 2017] [:error] [pid 32767]   File "/opt/python/run/venv/lib/python3.4/site-packages/tinys3/pool.py", line 4, in <module>
[Fri Nov 17 00:51:28.918539 2017] [:error] [pid 32767]     from concurrent.futures import ThreadPoolExecutor, as_completed
[Fri Nov 17 00:51:28.918540 2017] [:error] [pid 32767]   File "/opt/python/run/venv/lib/python3.4/site-packages/concurrent/futures/__init__.py", line 8, in <module>
[Fri Nov 17 00:51:28.918542 2017] [:error] [pid 32767]     from concurrent.futures._base import (FIRST_COMPLETED,
[Fri Nov 17 00:51:28.918543 2017] [:error] [pid 32767]   File "/opt/python/run/venv/lib/python3.4/site-packages/concurrent/futures/_base.py", line 381
[Fri Nov 17 00:51:28.918545 2017] [:error] [pid 32767]     raise exception_type, self._exception, self._traceback
[Fri Nov 17 00:51:28.918547 2017] [:error] [pid 32767]                         ^
[Fri Nov 17 00:51:28.918549 2017] [:error] [pid 32767] SyntaxError: invalid syntax

Boto原创根本不起作用。

我绝对需要能够将XML动态上传到S3。 不知道为什么这不会起作用。

1 个答案:

答案 0 :(得分:-1)

使用AWS Command line tools为我工作

  

aws s3 cp~ / myFiles / file.xml&lt; s3 URI&gt; --recursive