createObject: Create an object on a Member Node.

createObjectR Documentation

Create an object on a Member Node.

Description

This method provides the ability to upload a data or metadata object to the Member Node provided in the 'mnode' parameter.

Usage

createObject(x, ...)

## S4 method for signature 'MNode'
createObject(x, pid, file = as.character(NA), sysmeta, dataobj = NULL, ...)

Arguments

x

The MNode instance on which the object will be created

...

(Not yet used.)

pid

The identifier of the object to be created

file

the absolute file location of the object to be uploaded

sysmeta

a SystemMetadata instance describing properties of the object

dataobj

a raw object to use for the upload, instead of the contents of the file argument.

Details

In the version 2.0 library and higher, this operation can utilize an 'dataone_token' option to provide credentials for write operations in DataONE. The authentication token is obtained from DataONE (see your profile on https://search.dataone.org). See the vignette("dataone-overview") for details. Alternatively, the version 1.0 approach of using an X.509 certificate in a default location of the file system can also be used. This certificate provides authentication credentials from CILogon https://cilogon.org/?skin=DataONE. See vignette("dataone-overview") for details.

Value

a character containing the identifier that was created.

See Also

https://purl.dataone.org/architecture/apis/MN_APIs.html#MNStorage.create

Examples

## Not run: 
# Create an object in the DataONE "STAGING" environment
library(dataone)
library(uuid)
library(digest)
library(datapack)
cn <- CNode("STAGING")
mn <- getMNode(cn, "urn:node:mnStageUCSB2")
# 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)
format <- "text/csv"
size <- file.info(csvfile)$size
sha256 <- digest(csvfile, algo="sha256", serialize=FALSE, file=TRUE)
sysmeta <- new("SystemMetadata", identifier=newid, formatId=format, size=size, checksum=sha256)
sysmeta <- addAccessRule(sysmeta, "public", "read")
# Upload the data to DataONE (requires authentication)
\dontrun{
createObject(mn, newid, csvfile, sysmeta)
}

## End(Not run)

dataone documentation built on June 11, 2022, 1:06 a.m.