View | Details | Raw Unified | Return to bug 32888 | Differences between
and this patch

Collapse All | Expand All

(-)umc/widgets/MultiUploader.js (+4 lines)
 Lines 88-93    Link Here 
88
		// internal reference to the current Uploader widget
88
		// internal reference to the current Uploader widget
89
		_uploader: null,
89
		_uploader: null,
90
90
91
		// allow selecting of Multiple Files
92
		multiFile: false,
93
91
		// internal reference to the progress bar
94
		// internal reference to the progress bar
92
		_progressBar: null,
95
		_progressBar: null,
93
96
 Lines 232-237    Link Here 
232
				command: this.command,
235
				command: this.command,
233
				dynamicOptions: this.dynamicOptions,
236
				dynamicOptions: this.dynamicOptions,
234
				maxSize: this.maxSize,
237
				maxSize: this.maxSize,
238
				multiFile: this.multiFile,
235
				canUpload: this.canUpload,
239
				canUpload: this.canUpload,
236
				style: 'float: left;'
240
				style: 'float: left;'
237
			});
241
			});
(-)umc/widgets/Uploader.js (-4 / +12 lines)
 Lines 87-92    Link Here 
87
		//		A size limit for the uploaded file.
87
		//		A size limit for the uploaded file.
88
		maxSize: 524288,
88
		maxSize: 524288,
89
89
90
		//toggle mutliple files selectable
91
		multiFile: false,
92
90
		// make sure that no sizeClass is being set
93
		// make sure that no sizeClass is being set
91
		sizeClass: null,
94
		sizeClass: null,
92
95
 Lines 124-129    Link Here 
124
			this._uploader = new dojox.form.Uploader({
127
			this._uploader = new dojox.form.Uploader({
125
				url: '/umcp/upload' + (this.command ? '/' + this.command : ''),
128
				url: '/umcp/upload' + (this.command ? '/' + this.command : ''),
126
				label: this.buttonLabel,
129
				label: this.buttonLabel,
130
				multiple: this.multiFile,
127
				getForm: function() {
131
				getForm: function() {
128
					// make sure that the Uploader does not find any of our encapsulating forms
132
					// make sure that the Uploader does not find any of our encapsulating forms
129
					return null;
133
					return null;
 Lines 150-157    Link Here 
150
			this.inherited(arguments);
154
			this.inherited(arguments);
151
155
152
			// as soon as the user has selected a file, start the upload
156
			// as soon as the user has selected a file, start the upload
153
			this._uploader.on('change', lang.hitch(this, function(data) {
157
			this._uploader.on('change', lang.hitch(this, function(_data) {
154
				var allOk = array.every(data, function(ifile) {
158
				var allOk = array.every(_data, function(ifile) {
155
					return ifile.size <= this.maxSize;
159
					return ifile.size <= this.maxSize;
156
				}, this);
160
				}, this);
157
				if (!allOk) {
161
				if (!allOk) {
 Lines 159-165    Link Here 
159
					this._uploader.reset();
163
					this._uploader.reset();
160
				}
164
				}
161
				else {
165
				else {
162
					when(this.canUpload(data[0]), lang.hitch(this, function(doUpload) {
166
					var data = _data;
167
					if (data.length == 1){
168
						data = data[0];
169
					}
170
					when(this.canUpload(data), lang.hitch(this, function(doUpload) {
163
						if (!doUpload) {
171
						if (!doUpload) {
164
							// upload canceled
172
							// upload canceled
165
							this._uploader.reset();
173
							this._uploader.reset();
 Lines 182-188    Link Here 
182
						});
190
						});
183
						this._uploader.upload(params);
191
						this._uploader.upload(params);
184
						this._updateLabel();
192
						this._updateLabel();
185
						this.onUploadStarted(data[0]);
193
						this.onUploadStarted(data);
186
					}));
194
					}));
187
				}
195
				}
188
			}));
196
			}));
(-)univention-management-console-web-server (-23 / +44 lines)
 Lines 631-665    Link Here 
631
		global _upload_manager
631
		global _upload_manager
632
		req = umcp.Request('UPLOAD', arguments=[path])
632
		req = umcp.Request('UPLOAD', arguments=[path])
633
633
634
		self._log('info', '##### raw request: %r' % (req, ))
635
634
		options = []
636
		options = []
635
		body = {}
637
		body = {}
636
		for iid, ifield in args.iteritems():
637
			if isinstance(ifield, cherrypy._cpreqbody.Part):
638
				# field is a FieldStorage object
639
				store = ifield
640
				tmpfile = _upload_manager.add(req.id, store)
641
638
642
				# check if filesize is allowed
639
		def _check_field_storage(iid, ifield):
643
				st = os.stat(tmpfile)
640
			# field is a FieldStorage object
644
				max_size = int(configRegistry.get('umc/server/upload/max', 64)) * 1024
641
			store = ifield
645
				if st.st_size > max_size:
642
			tmpfile = _upload_manager.add(req.id, store)
646
					self._log('warn', 'file of size %d could not be uploaded' % (st.st_size))
647
					raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'The size of the uploaded file is too large')
648
643
649
				# check if enough free space is available
644
			# check if filesize is allowed
650
				min_size = int(configRegistry.get('umc/server/upload/min_free_space', 51200))  # kilobyte
645
			st = os.stat(tmpfile)
651
				s = os.statvfs(tmpfile)
646
			max_size = int(configRegistry.get('umc/server/upload/max', 64)) * 1024
652
				free_disk_space = s.f_bavail * s.f_frsize / 1024  # kilobyte
647
			if st.st_size > max_size:
653
				if free_disk_space < min_size:
648
				self._log('warn', 'file of size %d could not be uploaded' % (st.st_size))
654
					self._log('error', 'there is not enough free space to upload files')
649
				raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'The size of the uploaded file is too large')
655
					raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'There is not enough free space on disk')
656
650
657
				filename = store.filename
651
			# check if enough free space is available
658
				# some security
652
			min_size = int(configRegistry.get('umc/server/upload/min_free_space', 51200))  # kilobyte
659
				for c in ('<>/'):
653
			s = os.statvfs(tmpfile)
660
					filename = filename.replace(c, '_')
654
			free_disk_space = s.f_bavail * s.f_frsize / 1024  # kilobyte
655
			if free_disk_space < min_size:
656
				self._log('error', 'there is not enough free space to upload files')
657
				raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'There is not enough free space on disk')
661
658
662
				options.append({'filename': filename, 'name': store.name, 'tmpfile': tmpfile})
659
			filename = store.filename
660
			# some security
661
			for c in ('<>/'):
662
				filename = filename.replace(c, '_')
663
664
			options.append({'filename': filename, 'name': store.name, 'tmpfile': tmpfile})
665
666
667
		for iid, ifield in args.iteritems():
668
			self._log('info','###### iid, ifield: %r ; %r' % (iid, ifield, ))
669
			if isinstance(ifield, cherrypy._cpreqbody.Part):
670
				self._log('info', '### One File for upload')
671
				_check_field_storage(iid, ifield)
672
			elif isinstance(ifield, list):
673
				self._log('info', '### Several Files for upload')
674
				self._log('info', '### ifield: %r' % (ifield, ))
675
				for jfield in ifield:
676
					self._log('info', '### jfield: %r' % (jfield, ))
677
					if isinstance(jfield, cherrypy._cpreqbody.Part):
678
						_check_field_storage(iid, jfield)
679
					else:
680
						# we cannot handle any other type
681
						CORE.warn('Unknown type of multipart/form entry: %s=%s' % (iid, ifield))
663
			elif isinstance(ifield, basestring):
682
			elif isinstance(ifield, basestring):
664
				# field is a string :)
683
				# field is a string :)
665
				body[iid] = ifield
684
				body[iid] = ifield
 Lines 684-689    Link Here 
684
703
685
		response = self.get_response(sessionid, path, kwargs)
704
		response = self.get_response(sessionid, path, kwargs)
686
705
706
		self._log('info','#### response %r' % (response, ))
707
687
		# check if the request is a iframe upload
708
		# check if the request is a iframe upload
688
		if 'iframe' in kwargs and (kwargs['iframe'] not in ('false', False, 0, '0')):
709
		if 'iframe' in kwargs and (kwargs['iframe'] not in ('false', False, 0, '0')):
689
			# this is a workaround to make iframe uploads work, they need the textarea field
710
			# this is a workaround to make iframe uploads work, they need the textarea field

Return to bug 32888