I am making a software that detect if a new file is uploaded into the Google Cloud Platform's bucket storage from virtual machine instance. A file directory named images was mounted to the bucket using Cloud Storage Fuse by this command
gcsfuse cloud-storage-bucket ~/mystuff/images
Whenever a file is uploaded into the bucket storage, the file will also appear in the images directory. I am using Python Watchdog package to detect if a new file is created
# -*- coding: utf-8 -*-
#!/bin/bash
import time
import TextDetector
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
DIR="~/mystuff/images"
class ExampleHandler(FileSystemEventHandler):
def on_created(self, event): # when file is created
# do something, eg. call your function to process the image
print("Got event for file %s" % event.src_path)
TextDetector.detect_text(event.src_path)
observer = Observer()
event_handler = ExampleHandler() # create event handler
# set observer to use created handler in directory
observer.schedule(event_handler, path=DIR)
observer.start()
# sleep until keyboard interrupt, then stop + rejoin the observer
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
The problem is the watchdog did not detect anything even when there is a new file created in the images directory every time I uploaded something in the bucket storage. I also tried using inotify but the result is also the same. The code runs without any problem when I tried locally in Windows platform. I am actually quite new to Ubuntu. Could anyone help me to solve this problem?