Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSResponseError: 400 Bad Request #124

Closed
dcgoss opened this issue Feb 29, 2016 · 0 comments · Fixed by #125
Closed

GSResponseError: 400 Bad Request #124

dcgoss opened this issue Feb 29, 2016 · 0 comments · Fixed by #125
Labels

Comments

@dcgoss
Copy link
Contributor

dcgoss commented Feb 29, 2016

Every time I try to python manage.py collect static, I get an error.

(venv)Dereks-MBP:pickle_django dcgoss$ python manage.py collectstatic --noinput
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.arg)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.arg)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_arg
    self.execute(*args, **cmd_options)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
    collected = self.collect()
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 107, in collect
    handler(path, prefixed_path, storage)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/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 "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 234, in delete_file
    if self.storage.exists(prefixed_path):
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 442, in exists
    return k.exists()
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/boto/s3/key.py", line 539, in exists
    return bool(self.bucket.lookup(self.name, headers=headers))
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/boto/s3/bucket.py", line 143, in lookup
    return self.get_key(key_name, headers=headers)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/boto/gs/bucket.py", line 108, in get_key
    query_args_l=query_args_l)
  File "/Users/dcgoss/Desktop/PickleApp/PickleBackend/venv/lib/python3.4/site-packages/boto/s3/bucket.py", line 231, in _get_key_internal
    response.status, response.reason, '')
boto.exception.GSResponseError: GSResponseError: 400 Bad Request

Here are my settings:

GS_BUCKET_NAME = os.environ['GCS_BUCKET_NAME']
GS_ACCESS_KEY_ID = os.environ['GCS_ACCESS_KEY']
GS_SECRET_ACCESS_KEY = os.environ['GCS_SECRET_KEY']

GS_CUSTOM_DOMAIN = '{bucket_name}.storage.googleapis.com'.format(bucket_name=GS_BUCKET_NAME)
MEDIA_FILES_LOCATION = 'media'
DEFAULT_FILE_STORAGE = 'pickle_core.settings.custom_storages.MediaStorage'
MEDIA_URL = "https://{host}/{media_files_extension}/".format(host=GS_CUSTOM_DOMAIN,
                                                             media_files_extension=MEDIA_FILES_LOCATION)
STATIC_FILES_LOCATION = 'static'
STATICFILES_STORAGE = 'pickle_core.settings.custom_storages.StaticStorage'
STATIC_URL = "https://{host}/{static_files_extension}/".format(host=GS_CUSTOM_DOMAIN,
                                                               static_files_extension=STATIC_FILES_LOCATION)

The custom storages references look like this:

class MediaStorage(GSBotoStorage):
    location = settings.MEDIA_FILES_LOCATION


class StaticStorage(GSBotoStorage):
    location = settings.STATIC_FILES_LOCATION

They are just there so I can access folders in my bucket.

dcgoss added a commit to dcgoss/django-storages that referenced this issue Feb 29, 2016
The value of this setting used to be derived from the parent class, S3BotoStorage. The value in the parent class was: `host = setting('AWS_S3_HOST', S3Connection.DefaultHost)`, which resolved to 's3.amazonaws.com' instead of the correct 'storage.googleapis.com'.
This fixed jschneier#124 for me.
jschneier added a commit that referenced this issue Mar 1, 2016
Added host setting to GSBotoStorage (fixes #124)
jschneier added a commit that referenced this issue Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants