Changes for page WOFileUpload

Last modified by David Holt on 2012/01/30 22:18

From version 41.1
edited by Johan Henselmans
on 2023/11/13 11:57
Change comment: Renamed back-links.
To version 36.1
edited by Pascal Robert
on 2012/01/30 22:18
Change comment: There is no comment for this version

Summary

Details

Page properties
Parent
... ... @@ -1,1 +1,0 @@
1 -documentation.Home.Development Architecture.Dynamic Elements.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.johanhenselmans
1 +XWiki.probert
Content
... ... @@ -1,8 +1,8 @@
1 -{{toc/}}
1 +{{toc}}{{/toc}}
2 2  
3 3  = Introduction =
4 4  
5 -The **WOFileUpload** element allows you 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 an HTML 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 allows you 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 an HTML form ([[WOForm]]) element and the //enctype// binding of the form must be set to "multipart/form-data" (see the examples).
6 6  
7 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.
8 8  
... ... @@ -25,126 +25,32 @@
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 +|= Binding Name |= Binding Type |= In/Out |= Required |= Description
29 +| filePath | String | in | Yes | 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}}
30 +| data | NSData | out | No | 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.
31 +| inputStream | String | in | No | 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.
32 +| bufferSize | int | in | No | 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.
33 +| outputStream | String | out | No | WebObjects copies the file upload data from the content to the outputStream specified by this attribute.
34 +| streamToFilePath | String | in | No | 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.
35 +| overwrite | boolean | in | No | When streamToFilePath is specified, this binding determines whether WebObjects should overwrite an existing file. Defaults to false.
36 +| finalFilePath | String | out | No | 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}}
38 += Examples =
53 53  
40 +== Java methods ==
54 54  
55 -)))
56 -|(((
42 +{{code}}
57 57  
58 58  
45 +{{/code}}
59 59  
47 +== WOD-style ==
60 60  
61 -data
62 -)))|(((
63 -NSData
64 -)))|(((
65 -out
66 -)))|(((
67 -No
68 -)))|(((
69 -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.
70 -)))
71 -|(((
72 -inputStream
73 -)))|(((
74 -String
75 -)))|(((
76 -in
77 -)))|(((
78 -No
79 -)))|(((
80 -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.
81 -)))
82 -|(((
83 -bufferSize
84 -)))|(((
85 -int
86 -)))|(((
87 -in
88 -)))|(((
89 -No
90 -)))|(((
91 -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.
92 -)))
93 -|(((
94 -outputStream
95 -)))|(((
96 -String
97 -)))|(((
98 -out
99 -)))|(((
100 -No
101 -)))|(((
102 -WebObjects copies the file upload data from the content to the outputStream specified by this attribute.
103 -)))
104 -|(((
105 -streamToFilePath
106 -)))|(((
107 -String
108 -)))|(((
109 -in
110 -)))|(((
111 -No
112 -)))|(((
113 -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.
114 -)))
115 -|(((
116 -overwrite
117 -)))|(((
118 -boolean
119 -)))|(((
120 -in
121 -)))|(((
122 -No
123 -)))|(((
124 -When streamToFilePath is specified, this binding determines whether WebObjects should overwrite an existing file. Defaults to false.
125 -)))
126 -|(((
127 -finalFilePath
128 -)))|(((
129 -String
130 -)))|(((
131 -out
132 -)))|(((
133 -No
134 -)))|(((
135 -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).
136 -)))
49 +{{code}}
137 137  
138 -= Examples =
139 139  
140 -== Java methods ==
52 +{{/code}}
141 141  
142 -{{code/}}
143 -
144 -== WOD-style ==
145 -
146 -{{code/}}
147 -
148 148  == Inline bindings (WOOGNL) ==
149 149  
150 150  {{code}}
... ... @@ -162,9 +162,9 @@
162 162  
163 163  = Related documents =
164 164  
165 -[[ERXWOFileUpload>>url:http://wocommunity.org/documents/javadoc/wonder/latest/er/extensions/components/_private/ERXWOFileUpload.html||shape="rect"]]
166 - [[AjaxFileUpload>>url:http://wocommunity.org/documents/javadoc/wonder/latest/er/ajax/AjaxFileUpload.html||shape="rect"]]
167 - [[NSPathUtilities.lastPathComponent>>url:http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/foundation/NSPathUtilities.html#lastPathComponent(java.lang.String)||shape="rect"]]
168 - [[ERAttachment>>doc:documentation.ERAttachment Framework]]
169 - [[Database vs Filesystem>>doc:documentation.Home.Best Practices.Development-Database vs Filesystem.WebHome]]
170 - [[Localization and Internationalization>>doc:documentation.Home.Development Architecture.Localization.Development-Localization and Internationalization.WebHome]]
71 +[[ERXWOFileUpload>>http://wocommunity.org/documents/javadoc/wonder/latest/er/extensions/components/_private/ERXWOFileUpload.html]]
72 +[[AjaxFileUpload>>http://wocommunity.org/documents/javadoc/wonder/latest/er/ajax/AjaxFileUpload.html]]
73 +[[NSPathUtilities.lastPathComponent>>http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/foundation/NSPathUtilities.html#lastPathComponent(java.lang.String)]]
74 +[[ERAttachment>>ERAttachment Framework]]
75 +[[Database vs Filesystem>>Development-Database vs Filesystem]]
76 +[[Localization and Internationalization>>Development-Localization and Internationalization]]