in container-filetransfer/cloud-transfer.py [0:0]
def upload(path, url, force_handler=None):
"""
Uploads a local file or directory to remote storage. Assumes that path is a
local file or directory, and determines the most upload appropriate handler
given the url type.
"""
logger = logging.getLogger(logger_name)
if not os.path.exists(path):
logging.error(f"Skipping upload to '{url}': '{path}' does not exist")
handlers = {
'sftp': upload_sftp,
'ftp': upload_ftp,
'ftps': upload_ftp,
'https': upload_http_auto,
'blob': upload_azure_blob,
's3': upload_amazon_s3,
'gs': upload_google_storage,
'': local_copy
}
if force_handler:
handler = force_handler
else:
handler = urlparse(url).scheme
if handler not in handlers:
logger.error(f"Skipping upload of '{url}': no implemented handlers for '{handler}'")
return False
logger.debug(f"Starting upload of '{path}' to '{url}'")
try:
handlers[handler](path, url)
except PermissionError:
logger.exception(f"Skipping upload of '{path}' to '{url}' because of insufficient permissions")
except Exception:
logger.exception(f"Upload of '{path}' to '{url}' failed")