def get_s3_bucket_key()

in app/source/dragen/src/dragen_qs.py [0:0]


def get_s3_bucket_key(s3_url):
    try:
        s3_url = s3_url.strip()
        if s3_url.find('s3://') != 0:
            raise Exception('Not S3 URL - could not get bucket and key')
        # Extract the bucket and key
        s3_path = s3_url.replace('//', '/')
        s3_bucket = s3_path.split('/')[1]
        s3_key = '/'.join(s3_path.split('/')[2:])
        return True, s3_bucket, s3_key
    # Confirm S3 URL
    except Exception as e:
        return False, None,  None