Description Usage Arguments Details Value Note Author(s) See Also Examples
Functions for manipulating the files belonging to an entity.
1 2 3 | addFile(entity, file, path)
deleteFile(entity, file)
moveFile(entity, src, dest)
|
entity |
The entity whose files will be modified. |
file |
A path to the file on the local file system, when adding, or the relative path to the file when deleting (see Details). |
path |
relative path in the entity's cache directory where the file should be placed. |
src |
full path to the source file relative to the entity's cache directory. |
dest |
destination path relative to the root of the entity's cache directory. |
Synapse has the ability to store only a single file for entities that are "locationable", which
are represented as the LocationOwner class in the Synapse R client. To get around the single file limitation,
the Synapse R client provides methods for maintaining a "cache" of files that can be zipped into a single
archive and uploaded to Synapse by calling the storeEntity
method.
When adding a file to an entity, the file
argument is the path to the file being added and
the path
argument is the relative path in the entity's cached directory where the file should be
placed. When moving or deleting a file, the file
and src
arguments should be the path to
the file that should be moved/deleted relative to the root of the cache directory.
The behavior of the dest
argument is slightly more complex. If this arguments contains
a trailing slash (i.e. "/"), they will be interpreted as a path to the directory in which the file
specified by the src
argument should be placed. Absent the trailing slash, dest
will be interpreted as a path followed by a filename to which the source file src
will be renamed.
The modified entity.
If the return value is not captured, the entity will not be modified.
Matthew D. Furia <matt.furia@sagebase.org>
addObject
moveObject
deleteObject
storeEntity
downloadEntity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## create a Data entity (LocationOwner sub-class).
entity <- Data()
## create a plot that will be added to the Media entity
datFile <- tempfile(fileext=".txt")
write.table(data.frame(diag(10)), file=datFile, row.names=F, col.names=F)
## add the file to the root of the entity's cache
## BE SURE TO CAPTURE THE RETURN VALUE
entity <- addFile(entity, datFile)
## move the file to a subdirectory named foo
entity <- moveFile(entity, entity$files[1], "/foo/")
## change the files name
entity <- moveFile(entity, entity$files[1], "/foo/plot.jpg")
## delete the file
entity <- deleteFile(entity, entity$files[1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.