in airavata_django_portal_sdk/user_storage/api.py [0:0]
def get_file_metadata(request, path, storage_resource_id=None, experiment_id=None):
if remoteapi.is_remote_api_configured():
resp = remoteapi.call(request,
"/user-storage/~/{path}",
path_params={"path": path},
params={"experiment-id": experiment_id},
raise_for_status=False
)
remoteapi.raise_if_404(resp, "User storage file path does not exist")
data = resp.json()
if data["isDir"]:
raise Exception("User storage path is a directory, not a file")
file = data['files'][0]
file['created_time'] = convert_iso8601_to_datetime(file['createdTime'])
file['modified_time'] = convert_iso8601_to_datetime(file['modifiedTime'])
file['mime_type'] = file['mimeType']
file['data-product-uri'] = file['dataProductURI']
return file
final_path, owner_username = _get_final_path_and_owner_username(request, path, experiment_id)
backend = get_user_storage_provider(request, storage_resource_id=storage_resource_id, owner_username=owner_username)
if backend.is_file(final_path):
_, files = backend.get_metadata(final_path)
file = files[0]
data_product_uri = _get_data_product_uri(request, file['resource_path'],
storage_resource_id=backend.resource_id,
owner=owner_username)
data_product = request.airavata_client.getDataProduct(
request.authz_token, data_product_uri)
mime_type = None
if 'mime-type' in data_product.productMetadata:
mime_type = data_product.productMetadata['mime-type']
file['data-product-uri'] = data_product_uri
file['mime_type'] = mime_type
# TODO: remove this, there's no need for hidden files
file['hidden'] = False
return file
else:
raise ObjectDoesNotExist("File does not exist at that path.")