oittaa / gcp-storage-emulator

Local emulator for Google Cloud Storage
BSD 3-Clause "New" or "Revised" License
152 stars 42 forks source link

Bucket Upload notification to PubSub #170

Open RodrigoFerretti opened 2 years ago

RodrigoFerretti commented 2 years ago

Description

The main goal is to have any bucket upload integrated with pubsub notification. I dont know if this feature doesnt exists yet in this emulator or if I`m doing it wrong

Example

After running the local emulator with docker-compose:

version: "3"

services:
  gcs:
    container_name: gcs
    image: oittaa/gcp-storage-emulator
    ports:
      - 9023:9023
    environment:
      PORT: 9023

I then tried to run the following code whitout success:

import os
import google.cloud.storage as gcs
from google.cloud.storage.notification import BucketNotification

os.environ["STORAGE_EMULATOR_HOST"] = 'http://localhost:9023'

gcs_client: gcs.Client = gcs.Client()
gcs_client.create_bucket('bucket_name')

bucket: gcs.Bucket = gcs_client.get_bucket('bucket_name')
notification: BucketNotification = bucket.notification('topic_name', 'project_id')

notification.create(gcs_client)

It raises ConnectionError.

('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')

Any help or ideas? Thanks!

oittaa commented 2 years ago

It doesn't exist at the moment, but pull requests are welcome!