Data Management
The Data Management API provides users a way to store and access data across the Forge Platform.
Create a Bucket and Upload a File
To create a bucket, first get a token with the
bucket:create
, bucket:read
, and
data:write
scopes.
<- getToken(id = Sys.getenv("client_id"), secret = Sys.getenv("client_secret"),
resp = "bucket:create bucket:read data:write")
scope <- resp$content$access_token myToken
Then use the makeBucket()
function to create a bucket,
where bucket
is a name for the bucket.
<- makeBucket(token = myToken, bucket = "mybucket") resp
To check the status of a bucket:
<- checkBucket(token = myToken, bucket = "mybucket")
resp resp
Finally, to upload a file to the bucket, use the
uploadFile()
function, which returns an object containing
the bucketKey
, objectId
(i.e. urn),
objectKey
(i.e. file name), size
,
contentType
(i.e. “application/octet-stream”),
location
and other content information. Note the unique urn
of the file and store it in .Renviron
for future use.
<- uploadFile(file = system.file("samples/aerial.dwg", package = "AutoDeskR"),
resp = myToken, bucket = "mybucket")
token <- resp$content$objectId myUrn