Usually when we are trying to save the file with save attachment, with different filename we want, we need to read the attachment as filestream and then only we can change the name of the file else it will be created as folder by usual
Kindly have a look on this thread to the last comment that could definitely help you resolve this
this in addition
Kindly correct me if i have understood the query wrongly
Cheers @soumi_soumiya