def download_file(file_id): """ Get a presigned url to download a file given by file_id. """ result = get_signed_url_for_file("download", file_id) if not "redirect" in flask.request.args or not "url" in result: return flask.jsonify(result) return flask.redirect(result["url"])
def get_ga4gh_signed_url(object_id, access_id): if not access_id: raise UserError("Access ID/Protocol is required.") result = get_signed_url_for_file("download", object_id, requested_protocol=access_id) return flask.jsonify(result)
def upload_file(file_id): """ Get a presigned url to upload a file given by file_id. """ file_name = flask.request.args.get("file_name") if not file_name: logger.warning(f"file_name not provided, using GUID: {file_id}") file_name = str(file_id) result = get_signed_url_for_file("upload", file_id, file_name=file_name) return flask.jsonify(result)
def get_ga4gh_signed_url(object_id, access_id): if not access_id: raise UserError("Access ID/Protocol is required.") ga4gh_passports = None if flask.request.method == "POST": ga4gh_passports = flask.request.get_json(force=True, silent=True).get( config["GA4GH_DRS_POSTED_PASSPORT_FIELD"]) if ga4gh_passports and flask.request.headers.get("Authorization"): raise UserError( "You cannot supply both GA4GH passports and a token " "in the Authorization header of a request.") result = get_signed_url_for_file( "download", object_id, requested_protocol=access_id, ga4gh_passports=ga4gh_passports, ) return flask.jsonify(result)
def upload_file(file_id): """ Get a presigned url to upload a file given by file_id. """ result = get_signed_url_for_file("upload", file_id) return flask.jsonify(result)