Wiki source code of Attachments

Version 18.1 by Caleb James DeLisle on 2011/04/11

Hide last authors
Raluca Moisa 14.2 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
Silvia Macovei 7.1 4
Vincent Massol 1.33 5 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.
Vincent Massol 1.1 6
Silvia Macovei 11.3 7 = Attaching a file =
Vincent Massol 1.1 8
Silvia Macovei 8.1 9 There are 3 possibilities to attach a file:
Vincent Massol 1.26 10
Silvia Macovei 11.3 11 == Using the top level menu ==
Vincent Massol 1.29 12
Raluca Moisa 14.2 13 Starting with XWiki 2.6, you can add an attachment using the new Add menu:
14
15 [[image:AddAttachmentsColibri.png]]
16 //Screenshot of the Colibri skin//
17
18 [[image:ViewAttachmentsColibri.png]]
19 //Screenshot of the Colibri skin//
20
Raluca Moisa 14.3 21 View the page on which you wish to attach a file and then select the "View > Attachments" option in the top level menu:
Vincent Massol 1.29 22
Raluca Moisa 14.2 23 [[image:ViewAttachments.png]]
Silvia Macovei 8.1 24 //Screenshot of the Toucan Skin//
Vincent Massol 1.26 25
Vincent Massol 1.29 26 You'll see a list of the current attachments and a possibility to upload more files:
27
Raluca Moisa 14.2 28 [[image:AttachmentBottomToucan.PNG]]
Silvia Macovei 8.1 29 //Screenshot of the Toucan Skin//
Vincent Massol 1.26 30
Silvia Macovei 11.3 31 == Using the attachment panel at the bottom of the page ==
Vincent Massol 1.26 32
Silvia Macovei 8.1 33 View the page on which you wish to attach a file and then click on "Attachments" at the bottom of the page.
Vincent Massol 1.29 34
Silvia Macovei 8.1 35 image:AttachmentBottomToucan.PNG
36 //Screenshot of the Toucan Skin//
37
38 image:AttachmentBottomColibri.PNG
39 //Screenshot of the Colibri Skin//
40
Silvia Macovei 11.3 41 == Using the WYSIWYG editor ==
Vincent Massol 1.29 42
Silvia Macovei 7.8 43 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:
Vincent Massol 1.29 44
Silvia Macovei 7.6 45 image:AttachmentWysiwygToucan.PNG
Vincent Massol 1.29 46
47 Note that you can create a link to the attachment/image directly in that same popup window.
48
Silvia Macovei 11.3 49 = Linking to an attached file/image =
Vincent Massol 1.29 50
Vincent Massol 11.5 51 If you're using the Wiki editor, you can use the [[Wiki Syntax>>platform:Main.XWikiSyntax]] to display an image inline or link to an attachment.
Vincent Massol 1.31 52
Silvia Macovei 7.8 53 If you're using the WYSIWYG editor, then use the "Link > Attached file..." or "Image > Insert image" buttons as shown above.
Vincent Massol 1.33 54
Silvia Macovei 11.3 55 = Linking to an external file/image =
Vincent Massol 1.33 56
Vincent Massol 1.35 57 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:
Vincent Massol 1.34 58
Vincent Massol 9.1 59 * **XWiki Syntax 1.0**: {{code language="none"}}[http://some_remote_server/path/to/file>text to display]{{/code}}
60 * **XWiki Syntax 2.0**: {{code language="none"}}[[text to display>>http://some_remote_server/path/to/file]]{{/code}}
Vincent Massol 1.34 61
62 For displaying an image located on a remote server, use the following HTML code snippet:
63
Vincent Massol 9.1 64 * **XWiki Syntax 1.0**: {{code language="xml"}}<img src="http://some_remote_server/path/to/image"/>{{/code}}
65 * **XWiki Syntax 2.0**: {{code language="none"}}image:http://some_remote_server/path/to/image{{/code}}
66
67 See the [[XWiki Syntax Guide>>platform:Main.XWikiSyntax]] for more details.
Caleb James DeLisle 17.1 68
Caleb James DeLisle 18.1 69 = Size Limit =
70 The maximum size of an attachment is limited by a a configuration parameter in XWikiPreferences document. It is set to about 10MB by default.
71 To change it:
72 1. Go to <yourwiki>/xwiki/bin/edit/XWiki/XWikiPreferences?editor=object
73 2. Click on the line that says ##XWikiPreferences 0## (right below the line that says ##Objects of type XWiki.XWikiPreferences (1)##)
74 3. Scroll down to the field that says ##Maximum Upload Size## and change the number to whatever size you want (it is expressed in bytes)
75 4. Scroll to the bottom and click save.
76
Caleb James DeLisle 17.1 77 = Attachment Storage =
78 XWiki offers plugin attachment storage mechanisms so you can store your attachments in the database or directly in the filesystem.
79
80 No matter what type of attachment store you use, the meta-data for the attachment will be saved in the [[xwikiattachment>>platform:DevGuide.DsXWikiAttachment]] table for faster loads.
81
82 == Database Attachment Store (Default) ==
83 This attachment storage mechanism stores your attachments in database entries in the [[xwikiattachment_content>>platform:DevGuide.DsXWikiAttachmentContent]], [[xwikiattachment_archive>>platform:DevGuide.XWikiAttachmentArchive]], and [[xwikiattrecyclebin>>platform:DevGuide.DsXwikiRecycleBin]] 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.
84
85 == Filesystem Attachment Store (Since XWiki Enterprise 3.0M2) ==
86
87 {{warning}}
88 The Filesystem Attachment Store is still in beta, it has passed all of our tests with flying colors but we need your help to make absolutely sure that everything is right before turning it on by default.
89 {{/warning}}
90
91 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.
92
93 === Directory Structure ===
94
95 [[image:FilesystemAttachmentStoreDirtree.png||height=300px]]
96
97 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.
98
99 === New users ===
100 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>>platform:AdminGuide.Configuration#HSamplexwiki.cfg]].
101 These settings should read as follows:
102
103 {{code language="none"}}
104 xwiki.store.attachment.hint = file
105 xwiki.store.attachment.versioning.hint = file
106 xwiki.store.attachment.recyclebin.hint = file
107 {{/code}}
108
109 Also make sure they are not commented out.
110
111 === Users who already have a running wiki and want to switch to Filesystem Attachment Store ===
112 If you already have a wiki and want to take advantage of the Filesystem Attachment Store, you should use the [[extensions:Extension.Filesystem Attachment Porter]] to move your existing attachments onto the filesystem.
113
114 === Other considerations ===
115 * 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.

Get Connected