def upload()

in ark-demo/pipelines/nfhl/nfhl_gcs_stage.py [0:0]


def upload(filepath, gcs_bucket_name, gcs_path):
    gcs_client = storage.Client()
    gcs_bucket = gcs_client.bucket(gcs_bucket_name)
    gcs_filepath = '{}{}'.format(gcs_path, filepath)

    logging.info('Uploading {} to GCS...'.format(filepath))
    try:
        blob = gcs_bucket.blob(gcs_filepath)
        blob.upload_from_filename(filepath)
        os.remove(filepath)
        return gcs_filepath, 'success'
    except Exception as e:
        logging.warning(e)
        return None, e