Skip to content

Conversation

@Kuzmanov
Copy link

@Kuzmanov Kuzmanov commented Apr 28, 2024

Description

Adds support to read and write names for the file blocks.

Now, when you retrieve a file block (uploaded or external file), the name of the file is included in the response.
For example:

"file": {
  "type": "external",
  "external": {
    "url": "https://example.com/my-file.pdf"
  },
  "caption": [],
  "name": "my-file.pdf"
}

Also, it supports setting a custom file name when adding a file block (external file only, since Notion API doesn't support uploading files).

var request = new BlockAppendChildrenRequest()
{
    BlockId = "xxx",
    After = "yyy",
    Children = new List<IBlockObjectRequest>()
    {
        new FileBlockRequest()
        {
            File = new ExternalFile()
            {
                External = new ExternalFile.Info()
                {
                    Url = "https://example.com/my-external-file.pdf"
                },
                Name = "my-custom-file-name.pdf"
            }
        }
    }
};

await _notionClient.Blocks.AppendChildrenAsync(request);

Documentation reference:

@Kuzmanov Kuzmanov changed the title Add name property to FileObject Add support to read/write file name for the file block Apr 28, 2024
@KoditkarVedant KoditkarVedant linked an issue May 2, 2024 that may be closed by this pull request
@KoditkarVedant KoditkarVedant self-requested a review October 29, 2024 13:02
@KoditkarVedant KoditkarVedant merged commit 6fc72b0 into notion-dotnet:main Oct 29, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adds support to read and write names for the file blocks.

2 participants