I have a google-storage java client.
I want to rename a folder on the cloud.
It there a way to do it?
I saw the update post but i'm not sure how to change the name meta data.
here is my try but i don't know what to fill in "entity"
and there is no oac.setName()
public void renameDirectory(String oldPath, String newName) throws IOException {
final Storage gsClient = GCSlientFactory.get(PromptoConfig.s.GCP_PROJECT_ID).getGSClient();
final URI uri = URI.create(oldPath);
ObjectAccessControl oac = new ObjectAccessControl();
oac.setId("newName");
final Storage.ObjectAccessControls.Update update = gsClient.objectAccessControls().update(BUCKET_NAME, uri.toString().replace("gs://"+BUCKET_NAME+"/", ""), "", oac);
update.execute();
}
and also:
final Storage gsClient = GCSlientFactory.get(PromptoConfig.s.GCP_PROJECT_ID).getGSClient();
final URI uri = URI.create(oldPath);
ObjectAccessControl oac = new ObjectAccessControl();
oac.set("name", newName);
final Storage.ObjectAccessControls.Update update = gsClient.objectAccessControls().update(BUCKET_NAME, uri.toString().replace("gs://"+BUCKET_NAME+"/", ""), "allUsers", oac);
update.execute();