solution for upload files to mediawiki site

I am working on a tool which automates the process of uploading files to a mediawiki site.
i.e commons.wikipedia.org or your local mediawiki based wiki.

Wrote the python script.
You can get it here.

https://github.com/tshrinivasan/voice-recorder-for-tawictionary/blob/master/mediawiki-uploader.py

But, when I run it againt my local wiki, to upload the ogg files, it is not accepting it.
throwing the error like following.

$python mediawiki-uploader.py
Traceback (most recent call last):
  File “mediawiki-uploader.py”, line 96, in <module>
    upload_file(photo)
  File “mediawiki-uploader.py”, line 73, in upload_file
    picture.upload(fileobj=file_object,comment=caption, ignorewarnings=True)
  File “/usr/local/lib/python2.7/dist-packages/wikitools/wikifile.py”, line 228, in upload
    res = req.query()
  File “/usr/local/lib/python2.7/dist-packages/wikitools/api.py”, line 143, in query
    raise APIError(data[‘error’][‘code’], data[‘error’][‘info’])
wikitools.api.APIError: (u’filetype-banned’, u’This type of file is banned’)

it means that the ogg file format is not accepted in the mediawiki site.

How to allow the upload of the ogg files in the mediawiki site?

Add the following two lines in the file LocalSettings.php inside your mediawiki installation folder.

$wgStrictFileExtensions = False;

$wgFileExtensions = array(‘png’,’gif’,’jpg’,’jpeg’,’doc’,’xls’,’mpp’,’pdf’,’ppt’,’tiff’,’bmp’,’docx’, ‘xlsx’, ‘pptx’,’ps’,’odt’,’ods’,’odp’,’odg’, ‘ogg’);

After adding these lines, I can able to upload the ogg files to my local mediawiki site.

Thanks for Yuvaraj Pandian for getting the correct tokens to solve the issue.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s