google cloud platform – How to upload JSON string to GCP bucket using Python without having to write it to a file?

I have been uploading JSON file to GCP bucket like this

data_array is an array containing JSONs for each row. It looks like this “[{key1: value1, key2: value2},{key1: value1, key2: value2},{key1: value1, key2: value2}…]”

path_to_file = # i dump array to file   
blob = bucket.blob(blob_name)
#blob.upload_from_filename(path_to_file)


I want to skip this "dump to file" step and upload my array to GCP bucket directly.
blob.upload_from_string(path_to_file) 

This throws an error , all red, I don’t even understand why.

Is there any way to push array directly to bucket without having to write to file

Read more here: Source link