Changes for page WOFileUpload
Last modified by David Holt on 2012/01/30 22:18
To version 35.1
edited by Kieran Kelleher
on 2011/04/27 03:13
on 2011/04/27 03:13
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,1 +1,0 @@ 1 -documentation.Home.Development Architecture.Dynamic Elements.WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. probert1 +XWiki.kieran - Content
-
... ... @@ -1,10 +1,10 @@ 1 -{{toc/}} 1 +{{toc}}{{/toc}} 2 2 3 3 = Introduction = 4 4 5 -The **WOFileUpload** element allow syou to add an<input type=file> HTML element into your form, hence letting your users upload files to your server. This element must be inside anHTML form ([[doc:documentation.Home.Development Architecture.Dynamic Elements.WOForm.WebHome]]) element and the //enctype// binding of the form must be set to "multipart/form-data" (see the examples).5 +The **WOFileUpload** element allow you to add a <input type=file> HTML element into your form, hence letting your users to upload files to your server. This element must be inside a HTML form ([[WOForm]]) element and the //enctype// binding of the form must be set to "multipart/form-data" (see the examples). 6 6 7 -Starting with WebObjects 5.2, it is possible to stream file uploads so that the entire file is not stored in memory on the server while being uploaded.7 +Starting with WebObjects 5.2, it's now possible to stream file uploads so that the entire file is not stored in memory on the server while being uploaded. 8 8 9 9 = Usage = 10 10 ... ... @@ -25,125 +25,31 @@ 25 25 26 26 = Bindings = 27 27 28 -|=((( 29 -Binding Name 30 -)))|=((( 31 -Binding Type 32 -)))|=((( 33 -In/Out 34 -)))|=((( 35 -Required 36 -)))|=((( 37 -Description 38 -))) 39 -|((( 40 -filePath 41 -)))|((( 42 -String 43 -)))|((( 44 -in 45 -)))|((( 46 -Yes 47 -)))|((( 48 -The name of the file being uploaded, including the full path when the client is on Windows. To get only the name of the file without the full path, you can use 28 +| filePath | The name of the file being uploaded, including the full path when the client is on Windows. To get only the name of the file without the full path, you can use {{code}}NSPathUtilities.lastPathComponent(filePath){{/code}} 29 +| data | The file being uploaded will be stored in a [[NSData>>http://www.webobjects.me/API/wo542/com/webobjects/foundation/NSData.html]] object. Please note that the entire file will be in-memory, so beware of out-of-memory errors if users upload large files. 30 +| inputStream | The file will be streamed to a Java InputStream object that represents the content of the file. If you use that binding, you can only have one WOFileUpload element in your page, and it have to be the last element of the page and the form's multipleSubmit attribute must be set to false. 31 +| bufferSize | Sets the size (in bytes) of the buffer used by the outputStream and streamToFilePath attributes. The default buffer size is 512KB. There is no reasonable restriction on the buffer size. 32 +| outputStream | WebObjects copies the file upload data from the content to the outputStream specified by this attribute. 33 +| streamToFilePath | WebObjects writes the file upload data from the content directly to the file path specified in this attribute. This is an atomic operation~-~--the data is written to a temporary file, which is renamed when the process is complete. 34 +| overwrite | When streamToFilePath is specified, this binding determines whether WebObjects should overwrite an existing file. Defaults to false. 35 +| finalFilePath | When streamToFilePath is specified, its value is set to the actual file location (it may differ from the streamToFilePath value if there is a problem renaming the file). 49 49 50 -{{code}} 51 -NSPathUtilities.lastPathComponent(filePath) 52 -{{/code}} 37 += Examples = 53 53 39 +== Java methods == 54 54 55 -))) 56 -|((( 41 +{{code}} 57 57 58 58 44 +{{/code}} 59 59 60 -data 61 -)))|((( 62 -NSData 63 -)))|((( 64 -out 65 -)))|((( 66 -No 67 -)))|((( 68 -The file being uploaded will be stored in a [[NSData>>url:http://www.webobjects.me/API/wo542/com/webobjects/foundation/NSData.html||shape="rect"]] object. Please note that the entire file will be in-memory, so beware of out-of-memory errors if users upload large files. 69 -))) 70 -|((( 71 -inputStream 72 -)))|((( 73 -String 74 -)))|((( 75 -in 76 -)))|((( 77 -No 78 -)))|((( 79 -The binding will be set to an InputStream that points to the file upload. Note that the input stream points directly to the multipart request body part incoming stream and thus you **must** consume this input stream and close it inside the current request action logic. If you use this binding, you can only have one WOFileUpload element in your form, and it have to be the last element of the form and the form's multipleSubmit attribute must be set to false. Our advice, just use streamToFilePath. 80 -))) 81 -|((( 82 -bufferSize 83 -)))|((( 84 -int 85 -)))|((( 86 -in 87 -)))|((( 88 -No 89 -)))|((( 90 -Sets the size (in bytes) of the buffer used by the outputStream and streamToFilePath attributes. The default buffer size is 512KB. There is no reasonable restriction on the buffer size. 91 -))) 92 -|((( 93 -outputStream 94 -)))|((( 95 -String 96 -)))|((( 97 -out 98 -)))|((( 99 -No 100 -)))|((( 101 -WebObjects copies the file upload data from the content to the outputStream specified by this attribute. 102 -))) 103 -|((( 104 -streamToFilePath 105 -)))|((( 106 -String 107 -)))|((( 108 -in 109 -)))|((( 110 -No 111 -)))|((( 112 -WebObjects writes the file upload data from the content directly to the file path specified in this attribute. This is an atomic operation~-~--the data is written to a temporary file, which is renamed when the process is complete. 113 -))) 114 -|((( 115 -overwrite 116 -)))|((( 117 -boolean 118 -)))|((( 119 -in 120 -)))|((( 121 -No 122 -)))|((( 123 -When streamToFilePath is specified, this binding determines whether WebObjects should overwrite an existing file. Defaults to false. 124 -))) 125 -|((( 126 -finalFilePath 127 -)))|((( 128 -String 129 -)))|((( 130 -out 131 -)))|((( 132 -No 133 -)))|((( 134 -When streamToFilePath is specified, its value is set to the actual file location (it may differ from the streamToFilePath value if there is a problem renaming the file). 135 -))) 46 +== WOD-style == 136 136 137 - = Examples =48 +{{code}} 138 138 139 -== Java methods == 140 140 141 -{{code /}}51 +{{/code}} 142 142 143 -== WOD-style == 144 - 145 -{{code/}} 146 - 147 147 == Inline bindings (WOOGNL) == 148 148 149 149 {{code}} ... ... @@ -161,9 +161,8 @@ 161 161 162 162 = Related documents = 163 163 164 -[[ERXWOFileUpload>>url:http://wocommunity.org/documents/javadoc/wonder/latest/er/extensions/components/_private/ERXWOFileUpload.html||shape="rect"]] 165 - [[AjaxFileUpload>>url:http://wocommunity.org/documents/javadoc/wonder/latest/er/ajax/AjaxFileUpload.html||shape="rect"]] 166 - [[NSPathUtilities.lastPathComponent>>url:http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/foundation/NSPathUtilities.html#lastPathComponent(java.lang.String)||shape="rect"]] 167 - [[ERAttachment>>doc:documentation.ERAttachment Framework]] 168 - [[Database vs Filesystem>>doc:documentation.Home.Best Practices.Development-Database vs Filesystem.WebHome]] 169 - [[Localization and Internationalization>>doc:documentation.Development-Localization and Internationalization]] 70 +[[ERXWOFileUpload>>http://webobjects.mdimension.com/hudson/job/Wonder/javadoc/er/extensions/components/_private/ERXWOFileUpload.html]] 71 +[[AjaxFileUpload>>http://webobjects.mdimension.com/hudson/job/Wonder/javadoc/er/ajax/AjaxFileUpload.html]] 72 +[[ERAttachment>>WONDER:ERAttachment Framework]] 73 +[[Database vs Filesystem>>WO:Development-Database vs Filesystem]] 74 +[[Localization and Internationalization>>WO:Development-Localization and Internationalization]]