Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`HTTPS_PROXY`, depending on the protocol of the `url` passed. Proxy
Authentication `proxy_auth` should be passed as a `aiohttp.BasicAuth`
object. Proxy Headers `proxy_headers` should be passed as `dict`
object.
"""
overwrite = overwrite or self.overwrite
if path is None and filename is None:
raise ValueError("Either path or filename must be specified.")
elif path is None:
path = './'
path = pathlib.Path(path)
if not filename:
filepath = partial(default_name, path)
elif callable(filename):
filepath = filename
else:
# Define a function because get_file expects a callback
def filepath(*args):
return path / filename
scheme = urllib.parse.urlparse(url).scheme
if scheme in ('http', 'https'):
get_file = partial(self._get_http, url=url, filepath_partial=filepath,
overwrite=overwrite, **kwargs)
self.http_queue.put_nowait(get_file)
elif scheme == 'ftp':
if aioftp is None:
raise ValueError("The aioftp package must be installed to download over FTP.")