I am having files in GCP bucket already uploaded and want to prepend "attachment" value for all files content-disposition property using gs utils.
Below command we have for updating property
gcloud storage objects update gs://bucket_name/*.* --content-disposition="Attachment"
But I want to prepend "Attachment" value in existing property value.
I can loop to read all file's metadata using below script:
for FILEPATH in $(gsutil ls gs://dellord)
do
echo $FILEPATH
for METAPROP in $(gsutil ls -L $FILEPATH)
do
echo $METAPROP
done
But how to read particular content-disposition property and prepend in individual file property.
You might want to try printing the output as JSON, using
jqto filter it and print the name and new content-disposition of each object, and then having another program read in those JSON objects and update the metadata for each one. This command:Creates an
objects.jsonfile that might look something like this, with the updated content-disposition value and each object's name:You could then feed that
objects.jsonfile to a script that uses a loop to run agcloud storage objects updatecommand to update the content disposition of each object to the new specified value.