0

I am trying to upload files & images to the GCP bucket which I created a while ago. I am using Django rest-framework as the backend. I came across this library called [django storages][1]. I did everything stated in the library documentation.

  1. Create a service account, provided permission as storage admin and generated the json key.

  2. In my projects settings.py file I have declared these attributes -

DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"

GS_BUCKET_NAME = os.environ.get("GS_BUCKET_NAME")

GS_CREDENTIALS = service_account.Credentials.from_service_account_file("ibdax.json")

GS_PROJECT_ID="project-id"

Additionally, my models look exactly the same as said in the documentation.

But I still get this error -

{
    "error": "HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffffa84881d0>: Failed to establish a new connection: [Errno 111] Connection refused'))"
}

These are the logs -

Internal Server Error: /api/properties/create-property/
ibdax               | Traceback (most recent call last):
ibdax               |   File "/usr/local/lib/python3.7/site-packages/asgiref/sync.py", line 482, in thread_handler
ibdax               |     raise exc_info[1]
ibdax               |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 38, in inner
ibdax               |     response = await get_response(request)
ibdax               |   File "/usr/local/lib/python3.7/site-packages/django/utils/deprecation.py", line 138, in __acall__
ibdax               |     )(request, response)
ibdax               |   File "/usr/local/lib/python3.7/site-packages/asgiref/sync.py", line 444, in __call__
ibdax               |     ret = await asyncio.wait_for(future, timeout=None)
ibdax               |   File "/usr/local/lib/python3.7/asyncio/tasks.py", line 414, in wait_for
ibdax               |     return await fut
ibdax               | concurrent.futures._base.CancelledError
ibdax               | Application instance <Task pending coro=<StaticFilesWrapper.__call__() running at /usr/local/lib/python3.7/site-packages/channels/staticfiles.py:44> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/lib/python3.7/asyncio/futures.py:351, <TaskWakeupMethWrapper object at 0xffff8afea050>()]>> for connection <WebRequest at 0xffff8b38d810 method=POST uri=/api/properties/create-property/?property_files[O]&property_images[O]image: clientproto=HTTP/1.1> took too long to shut down and was killed.

After a long time API return this error response. Where am I going wrong.

2
  • Your software cannot connect to oauth2.googleapis.com. Your question needs details such as which service you are running your code on, network configuration, firewall rules, etc. Commented Feb 12, 2022 at 22:01
  • @Jeet Patel, As mentioned in the previous comment. Can you please provide more details? Commented Feb 14, 2022 at 21:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.