hydroshare / hs_restclient

Python client for the https://www.hydroshare.org REST API
BSD 3-Clause "New" or "Revised" License
6 stars 8 forks source link

hs.addResourceFile() should return file_id newly created #98

Open zhiyuli opened 5 years ago

zhiyuli commented 5 years ago

file_id = hs.addResourceFile(resource_id, file_local_path)

does not return the file_id newly created. it returns res_id

sblack-usu commented 5 years ago

I agree it should return the file_id, or at least the response body, which includes the file_id. Are you okay with me returning the whole response which will be a json map with the resource_id and file_id? The resource_id is kind of useless in the response, but it's there and I'd like to rest client to return the response instead of parsing it and tossing the rest.

sblack-usu commented 5 years ago

This has work on both the python rest_client and the rest_api. The rest_api will need to be updated to include the file_id in the response. Currently it only returns the resource_id and file_name. https://github.com/hydroshare/hydroshare/blob/develop/hs_core/views/resource_rest_api.py#L1128

The rest_client will have to be updated to return the json body for the response instead of parsing out the resource_id and returning only the resource_id. https://github.com/hydroshare/hs_restclient/blob/master/hs_restclient/__init__.py#L870

sblack-usu commented 5 years ago

hydroshare work will be done in https://github.com/hydroshare/hydroshare/issues/3088

zhiyuli commented 5 years ago

@sblack-usu

I am ok with returning the whole json body. I can extract the file_id by myself. Thanks!