Univention Bugzilla – Bug 31923
UMC-Server: support options for file upload
Last modified: 2023-06-09 16:30:25 CEST
Needed for Bug #26785 Options for other mime types than json are currently ignored. For example: The following command umc-command -U Administrator -P univention upload/schema -F share.schema -m image/png -o name=share.schema generates the following log file: PARSER ( PROCESS ) : Attribute options just available for MIME type application/json See Bug #31922, the options are needed for application/octet-stream.
A generic possible solution would be: Move the handling of files from the UMC-Webserver into the UMC-Server * The UMC-Webserver sends the content of the uploaded file as JSON to the UMC-Server (instead of creating a temporary file and only sending the filename) * The UMC-Server recognizes the file and writes it into a temporary file * The UMC-Modules will get the filename as before Options in umc-command prefixed with '@' will be treated as files (like in curl) to make it comfortable to upload files. The format of request.options for a UPLOAD UMCP-command would look like this: umc-upload -l -o myname=@foofile -o bar=baz { 'options': [{ 'filename': 'foofile', 'name': 'myname', 'value': 'The content of foofile', 'mimetype': 'The mimetype of foofile' }, { 'name': 'bar', 'value': 'baz' }] } (if not send as list): umc-upload -o myname=@foofile -o bar=baz { 'options': { 'myname': { 'filename': 'foofile', 'name': 'myname', 'value': 'The content of foofile', 'mimetype': 'The mimetype of foofile' }, 'bar': { 'name': 'bar', 'value': 'baz' } } } Additional the content of the file should be base64 encoded to minimize the JSON traffic. This can either be decided by specific binary mimetypes (PNG, JPEG), or generic with an additional field giving the encoding type.
Created attachment 5316 [details] file upload with request options.patch
(In reply to Florian Best from comment #2) > Created attachment 5316 [details] > file upload with request options.patch API Change: request.options is not a list anymore but a dict. All modules which uses UPLOAD must have slightly modifications. After applying this patch there can be done more optimizations, e.g.: * Remove CPUpload from UMC-Web-server, merge it with CPCommand and decide on the base of the request Content-Type header (application/json, application/www-form-urlencoded → COMMAND, multipart/form-data → UPLOAD)
Created attachment 5317 [details] patch for frontend uploader and UDM license upload
The UMC_Client should also be adapted to automatically add the fields filename, name, mimetype, encoding and content when the option value is prefixed by '@'.
I needed this functionality again in a customer project.
I have an idea how to implement the new format without breaking API compatibility: Since UCS 4.1 it is possible to upload files to /univention-management-console/command/ instead of /univention-management-console/upload/ (request content-type == multipart/form-data). This URI could use the new format then.
obsolete by Bug #43633 - it's possible to send various multipart/form-data fields to modules. *** This bug has been marked as a duplicate of bug 43633 ***