Beispiel #1
0
def index(_logged_user):
    """
    This is a example of file upload using
    Google Cloud Storage
    :return:
    """
    success_url = router.to_path(upload)
    bucket = get_default_gcs_bucket_name()
    logging.info(bucket)
    url = blobstore.create_upload_url(success_url, gs_bucket_name=bucket)
    cmd = blob_facade.list_blob_files_cmd(_logged_user)
    blob_form = blob_facade.blob_file_form()
    deletar_path_base = router.to_path(delete)
    download_path_base = router.to_path(download)

    def localizar_blob(blob):
        dct = blob_form.fill_with_model(blob, 64)
        dct['delete_path'] = router.to_path(deletar_path_base, dct['id'])
        dct['download_path'] = router.to_path(download_path_base, blob_key=blob.blob_key, filename=dct['filename'])
        return dct

    blob_files = [localizar_blob(b) for b in cmd()]
    context = {'upload_url': url,
               'blob_files': blob_files}
    return TemplateResponse(context, 'updown/home.html')
Beispiel #2
0
def index(_logged_user):
    """
    This is a example of file upload using
    Google Cloud Storage
    :return:
    """
    success_url = router.to_path(upload)
    bucket = get_default_gcs_bucket_name()
    logging.info(bucket)
    url = blobstore.create_upload_url(success_url, gs_bucket_name=bucket)
    cmd = blob_facade.list_blob_files_cmd(_logged_user)
    blob_form = blob_facade.blob_file_form()
    deletar_path_base = router.to_path(delete)
    download_path_base = router.to_path(download)

    def localizar_blob(blob):
        dct = blob_form.fill_with_model(blob, 64)
        dct['delete_path'] = router.to_path(deletar_path_base, dct['id'])
        dct['download_path'] = router.to_path(download_path_base,
                                              blob_key=blob.blob_key,
                                              filename=dct['filename'])
        return dct

    blob_files = [localizar_blob(b) for b in cmd()]
    context = {'upload_url': url, 'blob_files': blob_files}
    return TemplateResponse(context, 'updown/home.html')
Beispiel #3
0
def index():
    success_url = router.to_path(upload)
    bucket = get_default_gcs_bucket_name()
    logging.info(bucket)
    url = blobstore.create_upload_url(success_url, gs_bucket_name=bucket)
    cmd = blob_facade.list_blob_files_cmd()
    blob_form = blob_facade.blob_file_form()
    deletar_path_base = router.to_path(delete)
    download_path_base = router.to_path(download)

    def localizar_blob(blob):
        dct = blob_form.fill_with_model(blob, 64)
        dct['delete_path'] = router.to_path(deletar_path_base, dct['id'])
        dct['download_path'] = router.to_path(download_path_base, blob.blob_key, dct['filename'].encode('utf8'))
        return dct

    blob_files = [localizar_blob(b) for b in cmd()]
    context = {'upload_url': url,
               'blob_files': blob_files}
    return TemplateResponse(context, 'updown/home.html')
Beispiel #4
0
def index(_logged_user):
    success_url = router.to_path(upload)
    bucket = get_default_gcs_bucket_name()
    url = blobstore.create_upload_url(success_url, gs_bucket_name=bucket)

    cmd = blob_facade.list_blob_files_cmd(_logged_user)
    blob_files = cmd()
    delete_path = router.to_path(delete)
    download_path = router.to_path(download)
    blob_file_form = blob_facade.blob_file_form()

    def localize_blob_file(blob_file):
        blob_file_dct = blob_file_form.fill_with_model(blob_file, 64)
        blob_file_dct['delete_path'] = router.to_path(delete_path, blob_file_dct['id'])
        blob_file_dct['download_path'] = router.to_path(download_path,
                                                        blob_file.blob_key,
                                                        blob_file_dct['filename'])
        return blob_file_dct

    localized_blob_files = [localize_blob_file(blob_file) for blob_file in blob_files]
    context = {'upload_url': url,
               'blob_files': localized_blob_files}
    return TemplateResponse(context, 'updown/home.html')