Skip to content

Commit

Permalink
Merge 27f7e74 into 6aed5cb
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterious-progression committed May 7, 2021
2 parents 6aed5cb + 27f7e74 commit 64793d6
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 75 deletions.
2 changes: 2 additions & 0 deletions fence/blueprints/data/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ def download_file(file_id):
"""
Get a presigned url to download a file given by file_id.
"""
print("#### In download route #####")
result = get_signed_url_for_file("download", file_id)
print(f"Result : {result}")
if not "redirect" in flask.request.args or not "url" in result:
return flask.jsonify(result)
return flask.redirect(result["url"])
13 changes: 6 additions & 7 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ def get_bucket_region(self):
def get_signed_url(
self, action, expires_in, public_data=False, force_signed_url=True, **kwargs
):

print("AWS SIGNED URL")
aws_creds = get_value(
config, "AWS_CREDENTIALS", InternalError("credentials not configured")
)
Expand Down Expand Up @@ -877,16 +879,16 @@ def get_signed_url(
if public_data and not force_signed_url:
url = "https://storage.cloud.google.com/" + resource_path
elif public_data and _is_anonymous_user(user_info):
expiration_time = int(time.time()) + int(expires_in)
# expiration_time = int(time.time()) + int(expires_in)
url = self._generate_anonymous_google_storage_signed_url(
ACTION_DICT["gs"][action], resource_path, expiration_time
ACTION_DICT["gs"][action], resource_path, int(expires_in)
)
else:
expiration_time = int(time.time()) + int(expires_in)
# expiration_time = int(time.time()) + int(expires_in)
url = self._generate_google_storage_signed_url(
ACTION_DICT["gs"][action],
resource_path,
expiration_time,
int(expires_in),
user_info.get("user_id"),
user_info.get("username"),
r_pays_project=r_pays_project,
Expand Down Expand Up @@ -973,14 +975,11 @@ def _generate_google_storage_signed_url(
# use configured project if it exists and no user project was given
if config["BILLING_PROJECT_FOR_SIGNED_URLS"] and not r_pays_project:
r_pays_project = config["BILLING_PROJECT_FOR_SIGNED_URLS"]

final_url = cirrus.google_cloud.utils.get_signed_url(
resource_path,
http_verb,
expiration_time,
extension_headers=None,
content_type="",
md5_value="",
service_account_creds=private_key,
requester_pays_user_project=r_pays_project,
)
Expand Down
Loading

0 comments on commit 64793d6

Please sign in to comment.