Using API to upload media files?

One of the posts in the community shows how to upload media files (csv).

Using API to upload media files?

I would like to ask if I upload a csv file as an update to a file already in the server, would it overwrite that file? If not then how do I delete media files in the server using API so that I can upload an update?

Thanks