Ok, thanks. In my case, I it does not delete it at all but at the same time I realized that the newMediaObject does not create the attachment post… it just uploads the file to the filesystem. Maybe that is the reason why it also does not delete it after. Do you believe it is a bug or is there something in my code that prevents creation of the attachment post?