Overwrite a file on Box with out creating a new version

Highlighted
Occasional Contributor

Overwrite a file on Box with out creating a new version

Hello,

 

 I am trying to download a file, make some changes to the file and upload the file using .net sdk console app. I tried to upload the same file using the API UploadAsync but it gave an exception that file already exist. So I used the the API UploadNewVersionAsync to overwrite the file, but as the name suggest it creates a version. My requirement is to overwrite the file without creating a new version. Please let me know if that is possible.

 

Thanks,

Subhash

4 REPLIES 4
Highlighted
Box Employee

Re: Overwrite a file on Box with out creating a new version

Hi @badribax - There is no concept of a non-versioned file replacement in Box. All files in Box are assigned a unique file id, and when you replace them, the file id stays the same, but a new version id is created.

 

If you wish to 'replace' a file without preserving the history, I think you have two options:

1. Delete the file and upload a new one (note that the file id will change)

2. Upload the new file and remove past versions - https://developer.box.com/reference/delete-files-id-versions-id/

 

I am not sure if either of these satisfies your use case. Can you please elaborate why you wish to replace a file without preserving versions?

Highlighted
Trusted Contributor

Re: Overwrite a file on Box with out creating a new version

I’d also point out that if Box was to provide a way to overwrite a file without creating a new version, that’d be a pretty big gift to the ransomware writers of the world...

Highlighted
Occasional Contributor

Re: Overwrite a file on Box with out creating a new version

Thanks for the response and it helps.

However, what is the difference between overwrite vs upload & remove previous versions for a ransomware.

 

Highlighted
Trusted Contributor

Re: Overwrite a file on Box with out creating a new version

Box support can recover files for a small window of time even after they’ve been deleted. Presumably the sane would be true for old file versions.