in notifier.py [0:0]
def list_and_write(source_directory: str, links: List[str]):
print(f"Trying to traverse {source_directory} and write files...")
for root, dirs, files in os.walk(source_directory):
for file in files:
fullpath = os.path.join(root, file)
target_path = os.path.join(f"{time_now}", (fullpath))
content_type = get_content_type(file)
blob = bucket.blob(target_path)
blob.content_type = content_type
read_mode = "rb" if content_type == "image/png" else "r"
write_mode = "wb" if content_type == "image/png" else "w"
links.append(f"{root_url}{target_path}")
with (
open(fullpath, read_mode) as infile,
blob.open(write_mode, content_type=content_type) as f,
):
contents = infile.read()
f.write(contents)