def update(self, plugin: RepositoryPlugin) -> None: require(self.replica is None or self.replica == 'gcp') assert self.drs_path is not None drs_uri = plugin.drs_uri(self.drs_path) drs_client = plugin.drs_client() access = drs_client.get_object(drs_uri, access_method=AccessMethod.gs) assert access.headers is None url = furl(access.url) blob_name = '/'.join(url.path.segments) # https://github.com/databiosphere/azul/issues/2479#issuecomment-733410253 if url.fragmentstr: blob_name += '#' + unquote(url.fragmentstr) else: # furl does not differentiate between no fragment and empty # fragment if access.url.endswith('#'): blob_name += '#' blob = self._get_blob(bucket_name=url.netloc, blob_name=blob_name) expiration = int(time.time() + 3600) file_name = self.file_name.replace('"', r'\"') assert all(0x1f < ord(c) < 0x80 for c in file_name) disposition = f"attachment; filename={file_name}" signed_url = blob.generate_signed_url(expiration=expiration, response_disposition=disposition) self._location = signed_url
def update(self, plugin: RepositoryPlugin, authentication: Optional[Authentication]) -> None: require(self.replica is None or self.replica == 'gcp') assert self.drs_path is not None drs_uri = plugin.drs_uri(self.drs_path) drs_client = plugin.drs_client(authentication) access = drs_client.get_object(drs_uri, access_method=AccessMethod.gs) require(access.method is AccessMethod.https, access.method) require(access.headers is None, access.headers) signed_url = access.url args = furl(signed_url).args require('X-Goog-Signature' in args, args) self._location = signed_url