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.
Create a service account, provided permission as
storage adminand generated thejsonkey.In my projects
settings.pyfile 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.