Skip to content

Commit

Permalink
Merge pull request #113 from hydroshare/112-add-resource-to-folder
Browse files Browse the repository at this point in the history
#112 added folder option to request parameters
  • Loading branch information
sblack-usu authored Oct 17, 2019
2 parents 04f15d9 + f5402c0 commit b083417
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,9 @@ To upload files to a specific resource folder:
>>> from hs_restclient import HydroShare, HydroShareAuthBasic
>>> auth = HydroShareAuthBasic(username='myusername', password='mypassword')
>>> hs = HydroShare(auth=auth)
>>> options = {
"folder": "/path/to/folder",
"files": "local/path/to/file.txt"
}
>>> result = hs.resource('ID OF RESOURCE GOES HERE').files(options)
>>> local_file = "file_name.txt"
>>> resource_filename = "folder_name/file_name.txt"
>>> result = hs.addResourceFile('ID OF RESOURCE GOES HERE', local_file, resource_filename)

To create a referenced content file:

Expand Down
1 change: 1 addition & 0 deletions hs_restclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def _prepareFileForUpload(self, request_params, resource_file, resource_filename
else:
mime_type = mime_type[0]
request_params['file'] = (fname, fd, mime_type)
request_params['folder'] = os.path.dirname(fname)
return close_fd

def getResourceList(self, **kwargs):
Expand Down

0 comments on commit b083417

Please sign in to comment.