NCEAS / arcticdatautils

Utility functions in R for processing data for the Arctic Data Center
https://nceas.github.io/arcticdatautils/
Apache License 2.0
10 stars 20 forks source link

write a wrapper for creating a new DataObject #182

Closed laijasmine closed 3 years ago

laijasmine commented 3 years ago

arcticdatautils::publish_object() has a lot of nice functionality that would be nice to include in an Arctic Data Center (or even DataOne?) specific function:

  1. guessing and checking the format
    
    if (is.null(format_id)) {
    format_id <- guess_format_id(path)
    if (format_id == "application/xml") {
      stop(call. = FALSE, "No format_id was specified and this appears to be an XML document. Please specify the format_id and run this call again.")
    }
    warning(paste0("No format_id was specified so a guess was made based upon the file extension: ", 
      format_id, "."))
    }

check_format(format_id)


2. generating the id

pid <- new_uuid()


This will help reduce mistakes that might occur when creating a new dataObject

new("DataObject", id=paste0("urn:uuid:", UUIDgenerate()), format="application/octet-stream", filename= "../../../visitor/Flanner/mc_ssa_cal.tar.gz", targetPath = "mc_ssa_cal.tar.gz")