I followed the url tutorial below in the stackoverflow itself, and I would like to know how I can also have the option to list the files of a Buckt and then how I can download these files, below my current code to UPLOAD, I would like to supplement to DOWNLOAD and LIST the bucket files
import asyncio
import aiohttp
from aiofile import AIOFile
from gcloud.aio.storage import Storage
BUCKET_NAME = 'unscanned-malware-scann-lab'
FILE_NAME = 'testeArquivoUp.txt'
async def async_upload_to_bucket(blob_name, file_obj, folder='uploads'):
""" Upload csv files to bucket. """
async with aiohttp.ClientSession() as session:
storage = Storage(service_file='./creds.json', session=session)
status = await storage.upload(BUCKET_NAME, f'{folder}/{blob_name}', file_obj)
return status['selfLink']
async def main():
print('Começou a processar')
async with AIOFile(FILE_NAME, mode='r') as afp:
f = await afp.read()
url = await async_upload_to_bucket(FILE_NAME, f)
print(url)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())