caterva2.Root.upload#

Root.upload(localpath, dataset=None)#

Uploads a local dataset to this root.

Parameters:
  • localpath (Path) – Path of the local dataset to upload.

  • dataset (Path, optional) – Remote path where the dataset will be uploaded. If not provided, the dataset will be uploaded to the top level of this root.

Returns:

A instance of File or Dataset.

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