Upload PDFs and other files
Right now, MD files including images are nicely uploaded as Image blocks.
However, any references to local files such as PDF's or other files are not uploaded as file. They are uploaded as a link to a block.
Links to files on my local filesystem are broken once uploaded to Notion.
Would it be possible to have it upload local files as attachment blocks, perhaps with a parameter such as --local-files?
Hey there! I had the same problem and was debugging it. In my case the issue could be described as the following:
I was using Markdown exports from Joplin, which seems to represent PDF like this (so actually as a Link) in Markdown:
[This is a file.pdf](../_resources/This is a file.pdf)
There are two issues with this:
- "Linked" files do not get uploaded -> Solution: Use "images" for PDF embeds
- Spaces in file names seem to confuse mistletoe -> Solution: Rename files or escape spaces with
%20
So changing the original markdown to this helped me:

I created a small pre-processing script to go through all mkdown files in the directory and update it accordingly:
for filename in glob.glob('*.md'):
with open(os.path.join(os.getcwd(), filename), 'r') as f:
mkdwn = f.read()
while(True):
# Find link block with local resources path and pdf file
match = re.search(r'(?<!!)\[(.*)\]\(../_resources/(.*)\.pdf\)', mkdwn)
if(match == None):
break
new_path = match.group(2).replace(" ", "%20")
new_image_block = f""
# Combine new block with surrounding markdown
mkdwn = mkdwn[:match.span(0)[0]] + new_image_block + mkdwn[match.span(0)[1]:]
# Write changes
with open(filename, "w") as fw:
fw.write(mkdwn)