0
from google.cloud import storage


def list_blobs(bucket_name):
    """Lists all the blobs in the bucket."""
    # bucket_name = "your-bucket-name"

    storage_client = storage.Client()

When I am creating cloud function using http. Its not deploying.

# Note: Client.list_blobs requires at least package version 1.17.0.
blobs = storage_client.list_blobs(bucket_name)

for blob in blobs:
    print(blob.name)

1 Answer 1

1

You need to put the google-cloud-storage in the requirements.txt and check if a function with the same name exists as the entry point. The main file need to have a function with the same name as the entry point

Sign up to request clarification or add additional context in comments.

4 Comments

from google.cloud import storage from google.cloud import bigquery import time from random import randint def test_read(bucketName): storage_client = storage.Client() bucket = storage_client.get_bucket(bucketName) files = bucket.list_blobs(prefix='') fileList = [file.name for file in files ] myList = [i.split('/')[-1] for i in fileList] print(myList) read_from_storage(bucketName)
I have tried different code but its failing in deployment.
yes. I have mentioned packages in requirement and CF entry point is "list_blobs". Still its failing in deployment.
Could you let me see your code? I can help you better if you do, @VarshaSahu

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.