# NOT RUN {
library(dataone)
library(uuid)
library(digest)
cn <- CNode("STAGING")
mn <- getMNode(cn, "urn:node:mnStageUCSB2")
mnid <- mn@identifier
# Have Dataone create an identifier for you (requires authentication)
\dontrun{
newid <- generateIdentifier(mn, "UUID")
}
# Create an identifier manually
newid <- paste("urn:uuid:", UUIDgenerate(), sep="")
testdf <- data.frame(x=1:10,y=11:20)
csvfile <- paste(tempfile(), ".csv", sep="")
write.csv(testdf, csvfile, row.names=FALSE)
f <- "text/csv"
size <- file.info(csvfile)$size
sha256 <- digest(csvfile, algo="sha256", serialize=FALSE, file=TRUE)
sysmeta <- new("SystemMetadata", identifier=newid, formatId=f, size=size,
checksum=sha256, originMemberNode=mnid, authoritativeMemberNode=mnid)
# Upload data to DataONE (requires authentication)
\dontrun{
response <- createObject(mn, newid, csvfile, sysmeta)
}
# }
Run the code above in your browser using DataLab