0
votes

I´m unable to upload files to GCS using the example on the link below: https://cloud.google.com/python/getting-started/using-cloud-storage

It fails on the file storage.py, method: upload_file, exactly on the following call:

blob.upload_from_string(file_stream, content_type=content_type)

I've configured the ACL to myu bucket and enabled the required APIs as per the tutorial. I´ve also enabled billing.

I'm running the code on the local development server but using the GCS default bucket name configured on the project.

Python version 2.7

1
Can you show the traceback? - Dan Cornilescu
The development server does not really show an error or anything.... It just show http 500. Even running with the debug flags, the local development server is not so great for debugging I guess. I found that it fails on the blob.upload_from_string() by adding a couple of logging statements on the upload_file() method inside the storage.py file - Amauri Oliveira
Do you have debug enabled for your app? The traceback might only show if the flag is set. - Dan Cornilescu
I have the following on my main file: if name == "main": app.debug = True - Amauri Oliveira
Just enabled some more logging and found the following error message: Caused by SSLError(\"Can\'t connect to HTTPS URL because the SSL module is not available.\",)) - Amauri Oliveira

1 Answers

1
votes

I have taken a look at the Getting started tutorial, and for what I can see, it is built to be used in Python3 runtime.

You can check the app.yaml file, in the case of the tutorial 3-binary-data it is specifying the python3 runtime, and all the commands in the tutorial are thought to be used in Python3 as well (i.e. virtualenv -p python3 env builds an environment to be used with the python3 interpreter).

As well, the libraries used, for example google.cloud.storage are deprecated in Python 2.7 (you can check it here), not that it means that it is unusable in Python2.7, only that it is not supported, and this might cause issues.

I would recommend you to use Python3 instead of Python2.7, and check if the issue persists.