Create a Resource

The ‘Create a CompositeResource Resource’ feature allows the user to create a new CompositeResource resource in their HydroShare account, which would contain all files they intend to upload. The resources in the user’s HydroShare account are created with a certain amount of prerequisites like author name, keywords, metadata and the title of your resource. The Python API provided by HydroShare helps in completing this task. Below are step by step instructions on how to create a new resource.

The way you could go about performing this function is by following the instructions below:

Step 1: Sign into HydroShare using your credentials

In the boxes below enter your HydroShare username and password. If you need to make a HydroShare account, click here.

Step 2: Enter the metadata as indicated below

Enter the name of the Author and co-authors if you have any, this helps with sharing access and making things available to people who could contribute to the project.

The title of the project is basically the name of your resource. Try to keep it short, but descriptive in order to avoid confusion when others search for your data.

The keywords are used to sort your resource with respect to its type and helps others find your data quickly when searching for a resource using these keywords.

Type in your abstract in the tab below that would help explain your resource to another fellow user. Try not using more than 200 words.

Step 3: Choose the file that you want to upload to the new resource that you are creating and click the 'Create' button below:

Learn more:

To try this on your own, you can use the code snippet below that is used in this demonstration.

    
        from hs_restclient import HydroShare, HydroShareAuthBasic
        auth = HydroShareAuthBasic(username= 'username', password= 'password')
        hs = HydroShare(auth=auth)
        abstract = date_built
        keywords = owner.split(', ')
        rtype = 'CompositeResource'
        fpath = '/path/to/a/file'
        metadata = '[{"coverage":{"type":"period", "value":{"start":"01/01/2000", "end":"12/12/2010"}}}, {"creator":{"name":"Username"}}, {"creator":{"name":"Username2"}}]'
        extra_metadata = '{"key-1": "value-1", "key-2": "value-2"}'
        resource_id = hs.createResource(rtype, title, resource_file=fpath, keywords=keywords, abstract=abstract, metadata=metadata, extra_metadata=extra_metadata)
        messages.error(request, "Resource created successfully")
        if has_errors:    
        messages.error(request, "Please fix errors.")