def list_files(): """ http://127.0.0.1:8080/list_files?bucket_name=comp4312_1000 """ try: bucket_name = request.args.get("bucket_name", default="comp4312_1000", type=str) x = return_blobs(bucket_name) file_names = x result = jsonify(file_names) return result except: return "Invalid bucket name"
def list_files(): """ http://127.0.0.1:8080/list_files?bucket_name=comp4312_1000 """ try: bucket_name = request.args.get('bucket_name', default='comp4312_a2_0670448', type=str) file_names = [] file_names = return_blobs(bucket_name) result = jsonify(file_names) return result except: return "Invalid bucket name"
def list_files(): """ http://127.0.0.1:8080/list_files?bucket_name=comp4312_0870121 """ try: bucket_name = request.args.get('bucket_name', default='comp4312_0870121', type=str) file_names = [] file_names = return_blobs(bucket_name) # Hint: extract all files in bucket_name and assign to file_names result = jsonify(file_names) return result except: return "Invalid bucket name"
def list_files(): """ http://127.0.0.1:8080/list_files?bucket_name=comp4312_1000 """ try: bucket_name = request.args.get('bucket_name', default='comp4312_1000demo', type=str) file_names = [] ##################### # Your code is here # #################### # Hint: extract all files in bucket_name and assign to file_names from storage_list_files import return_blobs file_names = return_blobs(bucket_name) result = jsonify(file_names) return result except: return "Invalid bucket name"
def list_files(): """ http://127.0.0.1:8080/list_files?bucket_name=comp4312_asmt2_0869016 """ try: bucket_name = request.args.get('bucket_name', default='comp4312_asmt2_0869016', type=str) file_names = [] ##################### # Your code is here # ######my code###### file_names = return_blobs(bucket_name) #########my code########### # Hint: extract all files in bucket_name and assign to file_names result = jsonify(file_names) return result except: return "Invalid bucket name"
for fn, obj in zip(destination_file_names, source_blob_names): blob = bucket.blob(obj) blob.download_to_filename(fn) print("Blob {} downloaded to {}.".format(obj, fn)) # [END storage_download_file] if __name__ == "__main__": from storage_list_files import return_blobs # 1. List all files in the bucket "comp4312_studentID" on gcp and assign to source_blob_names bucket_name = "comp4312_studentid" source_blob_names = [] # Your code is here source_blob_names = return_blobs(bucket_name) # An example of returned values in source_blob_names # source_blob_names = ['dandelion1.jpg', 'dandelion2.jpg', 'dandelion3.jpg', # 'grass1.jpeg', 'grass2.jpeg', 'grass3.jpeg'] # 2. Create paths to save all files in source_blob_names and store in destination_file_names import os download_path = "images/download/" destination_file_names = [] # Your code is here destination_file_names = [ os.path.join(download_path, path) for path in source_blob_names ] # An example of returned values in destination_file_names