The file I'm looking for in Google Cloud Storage: init.sh
Full path: gs: //cw-data/spark_app_code/init.sh
>>> from google.cloud import storage >>> def is_exist(bucket_name,object): ... client = storage.Client() ... bucket = client.bucket(bucket_name) ... blob = bucket.get_blob(object) ... try: ... return blob.exists(client) ... except: ... return False ... >>> is_exist('cw-data','spark_app_code') False >>> is_exist('cw-data','spark_app_code/') True >>> is_exist('cw-data','init.sh') False >>> is_exist('cw-data','spark_app_code/init.sh') True >>> is_exist('cw-data','/init.sh') False >>>
Here, files are stored not as in local file systems, but in the form of keys. Thus, when searching for a file in Google repository, use the absolute path, not just the file name.
source share