Download a File

The ‘Download a File’ feature allows the user to download a specific folder or file from a HydroShare resource. The instruction below consists of two steps. Step 1 will search through a given resource and then generate a list of files available. Step 2 will allow for the user to select and download a file from the resource.

Our demonstration code here is comprised of two steps. Step 1 will query the resource and generate a list of files available therein. Step 2 will actually download a selected file from a resource.

Step 1: Get a List of Files in a Resource from HydroShare:

In the boxes below enter the user’s personal HydroShare username and password. If needed, make a HydroShare account by clicking here.

The resource ID is a unique identifier for every resource on HydroShare. You can find it by clicking on your resource in HydroShare, scrolling down to the “How to Cite” section, and copying the ID from the URL. This is an example hyperlink: https://www.hydroshare.org/resource/08c6e88adaa647cd9bb28e5d619178e0/ from which The 32 letter combination at the end is called the resource ID. The resource ID from the example hyperlink is 08c6e88adaa647cd9bb28e5d619178e0.

Resource ID

Step 2: Choose a File in the Resource and Download it:

Learn more:

To try this on your own, you can use the code snippet below, or download the full javascript file that is used in this demonstration

      
        from hs_restclient import HydroShare, HydroShareAuthBasic
        auth = HydroShareAuthBasic(username='myusername', password='mypassword')
        hs = HydroShare(auth=auth)
        fname = 'somefile.txt'
        fpath = hs.getResourceFile('ID OF RESOURCE GOES HERE', fname, destination='/directory/to/download/file/to')