Files in Synapse are versionable. Please see Files and Versioning for more information about how versions in Files work.
Uploading a new version follows the same steps as uploading a file
for the first time - use the same file name and store it in the same
location (e.g., the same parentId). It is recommended to add a comment
to the new version in order to easily track differences at a glance. The
testUpload.txt will now have a version of 2
and a comment describing the change.
# fetch the file in Synapse file_to_update <- synGet(file_id, downloadFile = FALSE) # create the second version as a separated file file_path <- tempfile("testUpload.txt") connection <- file(file_path) writeChar("this is version 2", connection, eos = NULL) close(connection) # save the local path to the new version of the file file_to_update$path <- file_path # add a version comment file_to_update$versionComment <- 'change the file content' # store the new file updated_file <- synStore(file_to_update)
Any change to a File will automatically update its version. If this
isn’t the desired behavior, such as minor changes to the metadata, you
forceVersion=FALSE with the Python client.
Important: Because Provenance is tracked by version, set
forceVersion=FALSE for minor changes to avoid breaking
# Get file from Synapse, set downloadFile = FALSE since we are only updating annotations file <- synGet(file_id, downloadFile = FALSE) # Add annotations file$annotations = c("fileType" = "bam", "assay" = "RNA-seq") # Store the file without creating a new version file <- synStore(file, forceVersion = FALSE)
To set Provenance without changing the file version: