caterva2.Root.upload#

Root.upload(localpath, dataset=None)#

Upload a local dataset to this root.

Parameters:
  • localpath (Path) – The path of the local dataset.

  • dataset (Path) – The remote path to upload the dataset to. If not provided, the dataset will be uploaded to this root in top level.

Returns:

A File or Dataset instance.

Return type:

File

Examples

>>> import caterva2 as cat2
>>> import numpy as np
>>> # To upload a file you must be registered as a user.
>>> urlbase = 'https://cat2.cloud/demo'
>>> root = cat2.Root('@personal', urlbase, dict(username='user@example.com', password='foo'))
>>> path = f'@personal/dir{np.random.randint(0, 100)}/ds-4d.b2nd'
>>> root.upload('root-example/dir2/ds-4d.b2nd')
<Dataset: @personal/root-example/dir2/ds-4d.b2nd>
>>> 'root-example/dir2/ds-4d.b2nd' in root
True