Nriver / trilium-py

Python client for ETAPI of Trilium Note. Trilium 的 Python版 ETAPI 客户端
GNU Affero General Public License v3.0
118 stars 27 forks source link

[feature requests] Upload file #5

Closed holoword closed 1 year ago

holoword commented 1 year ago

Sounds like markdown import only process image, sometime the markdown file contain link to other file, which not upload in this script.

Nriver commented 1 year ago

Hi, I've never tried linking files in markdown notes. Would you tell me what software you are using and provide a sample md including the file?

holoword commented 1 year ago

I just take markdown file import as an example, what i really need is ability to send a file to trilium note. since a cannot find out upload file API, but trilium restapi provide it since function create_note support type [ text, code, file, image, search, book. relationMap, render]. After a code view in this repo, I find it is easy to implement a file upload function. If I have time this weekend, I can make a pull requests. Also, Markdown file can attach file, the grammar as like image, but when converse to html use markdown2, the html tag is different. what I most used scene is book note. when I create a book note, I'd like to attachment the file(epub|pdf) in this markdown file, when next time I read my booknote, at least I have a copy of the book. Attachment is a simple markdown with file example in obsidian. Obsidian Vault.zip

Nriver commented 1 year ago

I tried to use obsidian-export to convert obsidian vault to ordinary markdown as explained here https://github.com/Nriver/trilium-py#import-from-obsidian.

But your the file in your sample does not seem to be handled properly by the tool. The square brackets in file name is causing issues like https://github.com/zoni/obsidian-export/issues/14.

holoword commented 1 year ago

Sorry for the export problem and late reply. I'm experience a hard weekday. The obsidian example is just a toy and not self test. Previously, I used Joplin which direct export markdown with file, you can try to upload. In Monday, I have success write a function with process file upload, but currently I have no time to format it, maybe after I complete my lifework I have time. joplinExport.zip

holoword commented 1 year ago

11 Just add file upload function firstly, the markdown file process next time.

BARaphael commented 1 year ago

@Nriver Hi, since #11 has been merged, can you create a new release and update pypi?

Nriver commented 1 year ago

I was waiting for his next pr. I will make a release anyway.

BARaphael commented 1 year ago

I was waiting for his next pr. I will make a release anyway.

Thanks

Nriver commented 1 year ago

Just pushed 0.7.5 to pypi

holoword commented 1 year ago

Sorry for the late, I'm currently prepare for job interview and too busy, may I have time next weekend!

Nriver commented 1 year ago

Good luck with your job interview.

holoword commented 1 year ago

I have finish code writing and function test. But I find some confused naming in API and parameter naming. Can you give some more parameter explanation about create function?

Nriver commented 1 year ago

Basically I'd write with snake_case. But when it comes to the parameters defined in etapi like noteId, https://github.com/zadam/trilium/blob/7fc2824325f6a6bcbbd2e18179d69dbd4ac65d09/src/etapi/notes.js#LL80C9-L80C9, I would prefer to use the same name even if it's camelCase not the snake_case.

Nriver commented 1 year ago

Implemented in 99d2197c42fffae4dea3f91d89246550a7440f7f