Notion Helper - v1.3.29
    Preparing search index...

    Function createBlock

    • Creates a file block.

      Parameters

      • options: string | Object

        A string representing the file URL, a file upload ID, or an options object.

        • string
        • Object
          • url

            The URL for the file.

          • id

            The ID of the file upload.

          • name

            The name of the file.

          • caption

            The caption as a string, an array of strings, or an array of rich text objects.

      Returns Object | null

      A file block object compatible with Notion's API, or null if the URL/ID is invalid.

      // Use with a file URL
      const externalFile = block.file.createBlock("https://collegeinfogeek.com/wp-content/uploads/2015/01/10steps-reddit.pdf");

      // Use with a file upload ID
      const fileUploadFile = block.file.createBlock("123e4567-e89b-12d3-a456-426614174000");

      // Use with options object for external file
      const externalFile = block.file.createBlock({
      url: "https://collegeinfogeek.com/wp-content/uploads/2015/01/10steps-reddit.pdf",
      name: "10 Steps to Earning Awesome Grades (preview)",
      caption: "The Reddit preview of the 10 Steps to Earning Awesome Grades book."
      });

      // Use with options object for file upload
      const fileUploadFile = block.file.createBlock({
      id: "123e4567-e89b-12d3-a456-426614174000",
      name: "10 Steps to Earning Awesome Grades (preview)",
      caption: "The Reddit preview of the 10 Steps to Earning Awesome Grades book."
      });