Upload to TWiki Add-On
Script to programmatically attach a file to any TWiki topic
Introduction
This is a small Perl script to programmatically attach a file to any TWiki topic. The script can be executed on any computer, it does not have to be on the server where TWiki is installed. This is a useful script to create mashups of TWiki and other applications.
Usage
To attach a file to a TWiki topic, type this on the command line:
./uploadtotwiki.pl -l <login> -c <comment> <file(s)> <TWiki URL>
and enter the password when prompted.
Supported command line parameters:
-
-l login - login name of TWiki account (optional)
-
-p password - password of TWiki account (optional)
-
-c 'comment' - comment of attached file (default: 'Uploaded by uploadtotwiki/2011-01-12')
-
-h 1 - hide attachment, 0 or 1 (default: 0)
-
-i 1 - inline attachment, e.g create link in topic text (default: 0)
-
-d 60 - delay in seconds between uploads of multiple files (default: 15)
-
file(s) - one or more local files to upload (required)
-
URL - view URL of TWiki topic, http or https protocol (required, must be last)
Example:
% ./uploadtotwiki.pl -l guest ./smile.gif http://twiki.org/cgi-bin/view/Sandbox/UploadTest
Uploading ./smile.gif to http://twiki.org/cgi-bin/view/Sandbox/UploadTest
Enter password for guest at twiki.org:
... upload finished.
%
Add-On Installation Instructions
Note: This is a command line tool for administrators; regular TWiki user can ignore this.
- Download the ZIP file from the Add-on Home (see below)
- Unzip
UploadToTWikiAddOn.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/UploadToTWikiAddOn.txt | Add-on topic |
tools/uploadtotwiki.pl | Add-on script |
- If inclined, move
uploadtotwiki.pl to a different location or server
- Run above example to test if the installation was successful
- Install CPAN:LWP if missing (see CPAN instructions)
Limitations
- At this time, support for ApacheLogin only; TemplateLogin support is pending.
- Upload of files fail silently (without error message) :
- if the file name has unsupported characters (
$, @, ^, space, etc). Workaround: Rename files before upload.
- if the CRSF protection flag is set in configure. Workaround: Disable
{CryptToken}{Enable} configure setting.
- if the user has no permission to update the topic.
Add-On Info
- Set SHORTDESCRIPTION = Script to programmatically attach a file to any TWiki topic
Related Topic: TWikiAddOns