I'm trying to upload a file to google cloud using the below Python code and it throws the list index out of range error. Can someone help me resolve this issue please ?
import sys
from sys import argv
from google.cloud import storage
def upload_blob(bucket_name, source_file_name, destination_blob_name):
"""Uploads a file to the bucket."""
# The ID of your GCS bucket
bucket_name = "test1"
# The path to your file to upload
source_file_name = "C:/Users/test/p3.csv"
# The ID of your GCS object
destination_blob_name = "Test_Upload"
kms_key_name ="C:/Users/test/df08d120148c00.json"
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name,kms_key_name=kms_key_name)
blob.upload_from_filename(source_file_name)
print(
f"File {source_file_name} uploaded to {destination_blob_name}."
)
if __name__ == "__main__":
upload_blob(
bucket_name=sys.argv[1],
source_file_name=sys.argv[2],
destination_blob_name=sys.argv[3],
)