kanasimi / wikiapi

JavaScript MediaWiki API for node.js
https://kanasimi.github.io/wikiapi/
BSD 3-Clause "New" or "Revised" License
50 stars 6 forks source link

Upload file only if file does not exist ? #26

Closed hugolpz closed 3 years ago

hugolpz commented 3 years ago

Hello, Is there a parameter for that, or should I first read the target page to check if it exists ?

I have a code working via

let pageData = await targetWiki.page(`File:${zi}-red.png`, {});
let isEmpty = pageData.wikitext==='';

It's more a documentation issue.

kanasimi commented 3 years ago

By default, the function will not overwrite files existed. It will throw if file exists.

hugolpz commented 3 years ago

(Add a { "force": true } options ?)

kanasimi commented 3 years ago

Add a { "ignorewarnings": 1 } to options

hugolpz commented 3 years ago

I see (search: ignorewarnings). So I can go to wikiapi.js or /_test_suite/test.js to find those hidden parameters. 😎

kanasimi commented 3 years ago

Well.. in fact, it is in https://www.mediawiki.org/wiki/API:Upload#Upload_warnings and https://commons.wikimedia.org/w/api.php?action=help&modules=upload Of course we can document it.

hugolpz commented 3 years ago

I like to write documentations and I still plan to do so with yours. But I still have to understand your project better. Today I understood that you base your parameters naming convention upon MediaWiki API. Good 🥇 It still have to understand more stuff before attacking your README.md. Your project is elegant, the code is easy to write and understand, and the development is active which is great. Your project has two major weak points :

A better readme will help to call over new devs. I know you work great alone, but at one point it's better to have teammates and reviewvers, who can fix things when you, Kanasimi, can't for various reasons.

PS: I will move this summary to a new issue in coming days.

kanasimi commented 3 years ago

Yes, I wish more people to join the program development :smiley: