Opal has an internal file system that is accessible through web services. The opal R package exposes files management related functions:

Setup the connection with Opal:

library(opal)
o <- opal.login('administrator', 'password', 'https://opal-demo.obiba.org')

Download a file:

opal.file_download(o, '/tmp/datashield.zip')

Download a file, protected by a password:

opal.file_download(o, '/tmp/datashield.zip', 'datashield-encrypted.zip', key='ABCDEFGHIJKL')

Upload the file at another location:

list.files()
opal.file_upload(o, 'datashield.zip', '/projects/datashield')

Create a folder and list folder content:

opal.file_mkdir(o, '/projects/datashield/foo')
opal.file_ls(o, '/projects/datashield')

Move file to the new folder and list folder content:

opal.file_mv(o, '/projects/datashield/datashield.zip', '/projects/datashield/foo')
opal.file_ls(o, '/projects/datashield/foo')

Rename the new folder and list folder content:

opal.file_mv(o, '/projects/datashield/foo', '/projects/datashield/bar')
opal.file_ls(o, '/projects/datashield')

Write a file from the Opal file system into the R server session workspace:

opal.file_write(o, '/projects/datashield/bar/datashield.zip')
opal.execute(o, 'list.files()')

Read back the file into the Opal file system:

opal.file_read(o, 'datashield.zip', '/projects/datashield/bar/ds.zip')
opal.file_ls(o, '/projects/datashield/bar')

Remove created folder and list folder content:

opal.file_rm(o, '/projects/datashield/bar')
opal.file_ls(o, '/projects/datashield')

Good practice is to free server resources by sending a logout request:

opal.logout(o)
unlink('datashield-encrypted.zip')
unlink('datashield.zip')


datashield/opal documentation built on May 14, 2019, 7:53 p.m.