Links

Upload PDF in page

Tags: #notion #upload #pdf #page #snippet #naas_drivers
Author: Florent Ravenel
Last update: 2023-04-28 (Created: 2023-04-28)
Description: This notebook explains how to upload a PDF in a Notion page using naas_drivers. It is usefull for organizations that need to share PDFs to their Notion pages.
References:

Input

Import libraries

from naas_drivers import notion
import naas

Setup Variables

  • PDF_url: PDF URL
  • notion_token: Notion token shared with your database
  • page_url: Notion page URL or ID
# Inputs
PDF_url = "https://ir.tesla.com/_flysystem/s3/sec/000156459021004599/tsla-10k_20201231-gen.pdf"
# Outputs
notion_token = naas.secret.get("NOTION_TOKEN") or "YOUR_TOKEN"
page_url = "https://www.notion.so/naas-official/Test-93655d0408c14923bcd305dd4599cda9?pvs=4"

Model

Upload PDF

page_id = page_url.split("/")[-1].split("?")[0].split("-")[-1]
page = notion.connect(notion_token).page.get(page_id)
page.pdf(PDF_url)
page.update()

Output

Display result

print("PDF uploaded in your page:", page_url)