Was the DOI generated by ResearchGate? In this case you cannot replace the file without creating a new page and generating a new DOI. Digital Object Identifiers (DOIs) always relate to a file, not to a publication, although often they are (wrongly) regarded as identifiers for publications. See https://help.researchgate.net/hc/en-us/articles/14293044585745-ResearchGate-DOIs: "Once a ResearchGate DOI has been generated for a research item, you’re no longer able to edit that research item. Instead, you should remove the research completely, re-upload it with the edits and generate a new DOI."
In this case you cannot replace the file without creating a new page and generating a new DOI. Digital Object Identifiers (DOIs) always relate to a file, not to a publication, although often they are (wrongly) regarded as identifiers for publications.Because DOIs are designed to be persistent, a DOI string can't be changed once registered, and DOIs can't be fully deleted. You can always update the metadata associated with a DOI, but the DOI string itself can't change, and once it's been registered, it will be included in your next content registration invoice.To update an existing record, you will need to make a PUT request to https://api.test.datacite.org/dois/{id} —replacing {id} with the DOI you wish to update—with a JSON payload in the request. See the API Reference for more information.If an online work has both a DOI and a URL, include only the DOI. If an online work has a URL but no DOI, include the URL in the reference as follows: For works without DOIs from websites (not including academic research databases), provide a URL in the reference