Let's say I have a file at /tmp/file.txt. Normally, if I copy another file to /tmp/file.txt, the file.txt contents are just updated with whatever I put there. However, it seems that when I run `dx upload file.txt --destination /tmp/file.txt` multiple times, it's possible for multiple versions of such a file to be created.
How can I tell `dx upload` to overwrite pre-existing files with the same name (which is what I always want), rather than making multiple objects that have the same human-readable name (which is what I never want)? From the `dx upload` instructions ( https://documentation.dnanexus.com/user/objects/uploading-and-downloading-files/small-sets-of-files/uploading-using-dx ), it was not clear to me.
Unfortunately, this is not possible by design. You would have to explicitly remove the file yourself. It was create this way for two reasons. One is to reserve provenience of data operation until you explicitly remove it. If the file you want to replaced is used as input of another job, it would be confusing if a new file with the same path would replace it and make it unable to track original file. The second reason is around data access level. The Uploader is a lower permission than Contribute or Admin who can remove data.
I think your example in saving temporary file in tmp folder is a good practice. Although you still need to manually remove them, it's still much easier than to save temporary files in multiple location making it hard to cut down storage.
Comments
2 comments
Unfortunately, this is not possible by design. You would have to explicitly remove the file yourself. It was create this way for two reasons. One is to reserve provenience of data operation until you explicitly remove it. If the file you want to replaced is used as input of another job, it would be confusing if a new file with the same path would replace it and make it unable to track original file. The second reason is around data access level. The Uploader is a lower permission than Contribute or Admin who can remove data.
I think your example in saving temporary file in tmp folder is a good practice. Although you still need to manually remove them, it's still much easier than to save temporary files in multiple location making it hard to cut down storage.
Thank you for confirming.
Please sign in to leave a comment.