def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_10000 """ try: bucket_name = "comp4312_a2_0670448" create_bucket(bucket_name=bucket_name) return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_10000 """ try: bucket_name = request.args.get('bucket_name', default='comp4213_1000', type=str) create_bucket(bucket_name) return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_0870121-2 """ try: bucket_name = "" bucket_name = request.args.get('bucket_name', default='comp4312_0870121-2', type=str) create_bucket(bucket_name) # Hint: obtain bucket_name then call a function to create a bucket named bucket_name return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_10000 """ try: bucket_name = "" ##################### bucket_name = "comp4312_assignment2_1092015" create_bucket(bucket_name=bucket_name) #################### # Hint: obtain bucket_name then call a function to create a bucket named bucket_name return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_10000 """ try: bucket_name = request.args.get("bucket_name", default="comp4312_1000", type=str) ##################### create_bucket(bucket_name) # Your code is here # #################### # Hint: obtain bucket_name then call a function to create a bucket named bucket_name return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=assignment02 """ try: bucket_name = "" bucket.storage_class = "COLDLINE" new_bucket = storage_client.create_bucket(bucket, location="us") bucket_name = bucket.name create_bucket(bucket_name) # Hint: obtain bucket_name then call a function to create a bucket named bucket_name return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_10000demo """ try: bucket_name = "" ##################### # Your code is here # #################### # Hint: obtain bucket_name then call a function to create a bucket named bucket_name bucket_name = request.args.get('bucket_name', default='comp4312_10000demo', type=str) from storage_create_bucket import create_bucket create_bucket(bucket_name=bucket_name) return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_assign2_0880562 """ try: bucket_name = "" ##################### # Your code is here # #################### # Hint: obtain bucket_name then call a function to create a bucket named bucket_name # gets the bucket name (bucket from storage_upload_files_sln) bucket_name = request.args.get('bucket_name', default='comp4312_0880562', type=str) # creates the bucket using create_bucket in storage_create_bucket create_bucket(bucket_name=bucket_name) return "Bucket {} created".format(bucket_name) except: return "Bucket name is either existing or invalid format"
def create_bk(): """ http://127.0.0.1:8080/create_bk?bucket_name=comp4312_asmt2_0869016 """ try: bucket_name = "" ##################### # Your code is here # ####my code ##### bucket_name = request.args.get('bucket_name', default='comp4312_asmt2_0869016', type=str) create_bucket(bucket_name=bucket_name) #####my code##### #################### # Hint: obtain bucket_name then call a function to create a bucket named bucket_name return "Bucket {} created".format(bucket_name) except NameError: return "Bucket name is either existing or invalid format\n" + NameError
# Your code is here for fn, obj in zip(source_file_names, destination_blob_names): blob = bucket.blob(obj) blob.upload_from_filename(fn) print("File {} uploaded to {}.".format(fn, obj)) # [END storage_upload_file] if __name__ == "__main__": from storage_create_bucket import create_bucket # 1. Create a bucket named "comp4312_studentid" on gcp bucket_name = "comp4312_1000demo" # Your code is here create_bucket(bucket_name=bucket_name) # 2. List all files in the 'images/upload/' folder and assign to source_file_names import glob upload_path = "images/upload/" source_file_names = [] # Your code is here source_file_names = glob.glob(upload_path + "*", recursive=True) # An example of returned values in source_file_names # source_file_names = ['images/upload/dandelion1.jpg', 'images/upload/dandelion2.jpg', # 'images/upload/dandelion3.jpg', 'images/upload/grass1.jpeg', # 'images/upload/grass2.jpeg', 'images/upload/grass3.jpeg'] # 3. Extract basename of each path in source_file_names to form destination_blob_names import os
bucket = storage_client.get_bucket(bucket_name) for i in range(len(source_file_names)): blob = bucket.blob(destination_blob_names[i]) blob.upload_from_filename(source_file_names[i]) print("File {} uploaded as {}.".format(source_file_names[i], destination_blob_names[i])) # [END storage_upload_file] if __name__ == "__main__": from storage_create_bucket import create_bucket # 1. Create a bucket named "comp4312_studentid" on gcp bucket_name = "comp4312_0870121" bucket = create_bucket(bucket_name) # 2. List all files in the 'images/upload/' folder and assign to source_file_names import glob upload_path = "./images/upload/" source_file_names = [] for file in glob.glob(upload_path + '*'): if file(upload_path == "README.md"): continue source_file_names.append(file) print(source_file_names) # An example of returned values in source_file_names # source_file_names = ['images/upload/dandelion1.jpg', 'images/upload/dandelion2.jpg',