Je suis en train mettre mes fichiers statiques dans un seau dans mon compte Amazon S3 Ma configuration est la suivante:fichiers statiques dans un seau Amazon S3 - erreur Django collectstatic
- J'ai installé ces paquets:
pip install django-storages-redux pip install django-boto
Mon fichier settings.py
est:
INSTALLED_APPS = [
...
'storages',
...
]
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
#With this configuration, the static files (projects and applications) will stayed centralized in one directory
STATIC_ROOT = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2] + ['static-content'])
#Amazon S3 Storage
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
#DEFAULT_FILE_STORAGE = 'storages.backends.s3.S3Storage'
AWS_ACCESS_KEY_ID = get_env_variable('AWS_ACCESS_KEY_ID'),
AWS_SECRET_ACCESS_KEY = get_env_variable('AWS_SECRET_ACCESS_KEY'),
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_STORAGE_BUCKET_NAME = 'neurorehabilitation-project'
Quand je lance des commandes collectstatic
, je reçois ce message:
(nrb_dev)➜ neurorehabilitation_project git:(master) ✗ python manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings.
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
collected = self.collect()
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 107, in collect
handler(path, prefixed_path, storage)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 321, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 234, in delete_file
if self.storage.exists(prefixed_path):
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/storages/backends/s3boto.py", line 431, in exists
k = self.bucket.new_key(self._encode_name(name))
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/storages/backends/s3boto.py", line 289, in bucket
self._bucket = self._get_or_create_bucket(self.bucket_name)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/storages/backends/s3boto.py", line 322, in _get_or_create_bucket
return self.connection.get_bucket(name, validate=self.auto_create_bucket)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/storages/backends/s3boto.py", line 278, in connection
proxy_port=self.proxy_port
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/s3/connection.py", line 190, in __init__
validate_certs=validate_certs, profile_name=profile_name)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/connection.py", line 569, in __init__
host, config, self.provider, self._required_auth_capability())
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/auth.py", line 977, in get_auth_handler
ready_handlers.append(handler(host, config, provider))
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/auth.py", line 134, in __init__
HmacKeys.__init__(self, host, config, provider)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/auth.py", line 71, in __init__
self.update_provider(provider)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/auth.py", line 138, in update_provider
super(HmacAuthV1Handler, self).update_provider(provider)
File "/home/bgarcial/.virtualenvs/nrb_dev/lib/python3.4/site-packages/boto/auth.py", line 75, in update_provider
self._hmac = hmac.new(self._provider.secret_key.encode('utf-8'),
AttributeError: 'tuple' object has no attribute 'encode'
(nrb_dev)➜ neurorehabilitation_project git:(master) ✗
Quels sont les éléments ou configurations dois-je prendre en compte pour envoyer mes fichiers statiques sur Amazon S3?
Je travaille avec python3.4 et Django 1.9
Merci @Alasdair, j'ai mes fichiers dans le seau. :RÉ. Je ne peux pas voir mes fichiers multimédias (téléchargements par l'utilisateur). Je suppose que je ne dis pas à Django que les télécharger Comment puis-je télécharger mes fichiers multimédia sur Amazon S3? Dans ce lien https://github.com/jschneier/django-storages/issues/6 en parler, j'ai suivi les instructions ... – bgarcial
Il serait préférable de poser une nouvelle question sur le téléchargement de fichiers multimédias, plutôt que demandant dans les commentaires. – Alasdair
J'ai écrit la question dans un autre fil http://stackoverflow.com/questions/34604034/putting-static-and-media-files-on-amazon-s3-bucket-media-files juste au cas où. Merci – bgarcial