Skip to content

Commit

Permalink
HDX-9963 force browser to download JSON files
Browse files Browse the repository at this point in the history
  • Loading branch information
ccataalin committed Jul 17, 2024
1 parent 958db03 commit 3d0233a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ckanext-hdx_package/ckanext/hdx_package/actions/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,14 +1061,16 @@ def hdx_get_s3_link_for_resource(context, data_dict):
filename = os.path.basename(res_dict['url'])
key_path = upload.get_path(res_dict['id'], filename)

force_download = res_dict.get('format').lower() in ['geojson', 'json']

try:
s3 = upload.get_s3_session()
client = s3.client(service_name='s3', endpoint_url=host_name)
# url = client.generate_presigned_url(ClientMethod='get_object',
# Params={'Bucket': bucket.name,
# 'Key': key_path},
# ExpiresIn=60)
url = generate_temporary_link(client, bucket.name, key_path)
url = generate_temporary_link(client, bucket.name, key_path, force_download)
return {'s3_url': url}

except ClientError as ex:
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ckantoolkit==0.0.3
dogpile.cache==1.3.0

# ckanext-s3filestore
-e git+https://github.com/OCHA-DAP/[email protected].0#egg=ckanext-s3filestore
-e git+https://github.com/OCHA-DAP/[email protected].1#egg=ckanext-s3filestore

# ckanext-security
-e git+https://github.com/OCHA-DAP/[email protected]#egg=ckanext-security
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# via -r requirements.in
-e git+https://github.com/OCHA-DAP/[email protected]#egg=ckanext-requestdata
# via -r requirements.in
-e git+https://github.com/OCHA-DAP/[email protected].0#egg=ckanext-s3filestore
-e git+https://github.com/OCHA-DAP/[email protected].1#egg=ckanext-s3filestore
# via -r requirements.in
-e git+https://github.com/OCHA-DAP/[email protected]#egg=ckanext-security
# via -r requirements.in
Expand Down

0 comments on commit 3d0233a

Please sign in to comment.