Create an object on a Member Node.

Share:

Description

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

Usage

1
2
3
4
createObject(x, ...)

## S4 method for signature 'MNode'
createObject(x, pid, file, sysmeta)

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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)
## Not run: 
newid <- generateIdentifier(mn, "UUID")

## End(Not run)
# 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
sha1 <- digest(csvfile, algo="sha1", serialize=FALSE, file=TRUE)
sysmeta <- new("SystemMetadata", identifier=newid, formatId=format, size=size, checksum=sha1)
sysmeta <- addAccessRule(sysmeta, "public", "read")
# Upload the data to DataONE (requires authentication)
## Not run: 
createObject(mn, newid, csvfile, sysmeta)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.