Attachments
A page can contain attachments which can then later be referenced from within a page. For example this is very useful for attaching images and displaying them in the page's content.
Attaching a file
There are 3 possibilities to attach a file:
Using the top level menu
Starting with XWiki 2.6, you can add an attachment using the new Add menu:
Screenshot of the Colibri skin
Screenshot of the Colibri skin
View the page on which you wish to attach a file and then select the "View > Attachments" option in the top level menu:
Screenshot of the Toucan Skin
You'll see a list of the current attachments and a possibility to upload more files:
Screenshot of the Toucan Skin
Using the attachment panel at the bottom of the page
View the page on which you wish to attach a file and then click on "Attachments" at the bottom of the page.
Screenshot of the Toucan Skin
Screenshot of the Colibri Skin
Using the WYSIWYG editor
Edit the page on which you wish to attach a file using the WYSIWYG editor and click on "Link > Attached file..." in the toolbar. You can also click on "Image > Insert image" and you'll get a similar popup window as shown below:
Note that you can create a link to the attachment/image directly in that same popup window.
Linking to an attached file/image
If you're using the Wiki editor, you can use the Wiki Syntax to display an image inline or link to an attachment.
If you're using the WYSIWYG editor, then use the "Link > Attached file..." or "Image > Insert image" buttons as shown above.
Linking to an external file/image
If your file is on a remote server and you wish to link to it from your wiki, simply use the URL of the link as the content of your wiki link. For example, using the wiki editor you'd write:
- XWiki Syntax 1.0: [http://some_remote_server/path/to/file>text to display]
- XWiki Syntax 2.0: [[text to display>>http://some_remote_server/path/to/file]]
For displaying an image located on a remote server, use the following HTML code snippet:
- XWiki Syntax 1.0: <img src="http://some_remote_server/path/to/image"/>
- XWiki Syntax 2.0: image:http://some_remote_server/path/to/image
See the XWiki Syntax Guide for more details.
Attachment Storage
XWiki offers plugin attachment storage mechanisms so you can store your attachments in the database or directly in the filesystem.
No matter what type of attachment store you use, the meta-data for the attachment will be saved in the xwikiattachment table for faster loads.
Database Attachment Store (Default)
This attachment storage mechanism stores your attachments in database entries in the xwikiattachment_content, xwikiattachment_archive, and xwikiattrecyclebin tables. This system allows for easy backup of your attachments by dumping the database and keeps all of your data together but attachment size is memory constrained since the attachment content and archive must all be held in memory. As a general rule, attachments larger than 30MB are not possible.
Filesystem Attachment Store (Since XWiki Enterprise 3.0M2)
The Filesystem attachment store saves your attachments in files in a directory tree, this means you will have one more thing to do when you back up your data but it also means you can save larger (over one gigabyte) files. Filesystem attachment store implements a two stage commit mechanism to maintain integrity even if the database fails to commit the attachment meta-data.
Directory Structure
The Filesystem Attachment Store puts your attachments into a directory tree on the hard disk, the directory structure is designed to be intuitive to navigate but you should never add or remove anything. Each attachment is accompanied by a piece of meta-data in the database and modifying the content in the filesystem store manually will lead to meta-data with no content or content with no meta-data.
New users
If you are a new XWiki user, all you need to do for enabling Filesystem Attachment Store is to change some settings in the xwiki.cfg file.
These settings should read as follows:
xwiki.store.attachment.versioning.hint = file
xwiki.store.attachment.recyclebin.hint = file
Also make sure they are not commented out.
Users who already have a running wiki and want to switch to Filesystem Attachment Store
If you already have a wiki and want to take advantage of the Filesystem Attachment Store, you should use the Filesystem Attachment Porter to move your existing attachments onto the filesystem.
Other considerations
- If you are running a cluster you will need for each node to have a synchronized storage directory, you can use NFS or another means to mount the disk on each node in the cluster.