Bug 31923 - UMC-Server: support options for file upload
UMC-Server: support options for file upload
Status: RESOLVED DUPLICATE of bug 43633
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 5.0
Other Linux
: P5 enhancement (vote)
: ---
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-09 09:47 CEST by Stefan Gohmann
Modified: 2023-06-09 16:30 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Cleanup
Max CVSS v3 score:
best: Patch_Available+


Attachments
file upload with request options.patch (13.78 KB, patch)
2013-07-10 16:35 CEST, Florian Best
Details | Diff
patch for frontend uploader and UDM license upload (1.59 KB, patch)
2013-07-10 16:58 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2013-07-09 09:47:31 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.
Comment 1 Florian Best univentionstaff 2013-07-09 15:01:45 CEST
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.
Comment 2 Florian Best univentionstaff 2013-07-10 16:35:38 CEST
Created attachment 5316 [details]
file upload with request options.patch
Comment 3 Florian Best univentionstaff 2013-07-10 16:47:13 CEST
(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)
Comment 4 Florian Best univentionstaff 2013-07-10 16:58:16 CEST
Created attachment 5317 [details]
patch for frontend uploader and UDM license upload
Comment 5 Florian Best univentionstaff 2013-07-10 17:06:16 CEST
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 '@'.
Comment 6 Florian Best univentionstaff 2014-11-24 15:54:19 CET
I needed this functionality again in a customer project.
Comment 7 Florian Best univentionstaff 2016-02-05 14:45:10 CET
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.
Comment 8 Florian Best univentionstaff 2023-06-09 16:30:25 CEST
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 ***