# HG changeset patch # User Goffi # Date 1591676581 -7200 # Node ID 91b5ae058c66ce7700b439659983c5b5cd629a5a # Parent da443cf946ad7020ee287b515bfceb4fe542d449 comp file sharing: handle upload with headers: `Xmpp-File-Path` can now be used to specify file path, and `Xmpp-File-No-Http` when file must not be served publicly by HTTP. diff -r da443cf946ad -r 91b5ae058c66 sat/plugins/plugin_comp_file_sharing.py --- a/sat/plugins/plugin_comp_file_sharing.py Tue Jun 09 06:21:23 2020 +0200 +++ b/sat/plugins/plugin_comp_file_sharing.py Tue Jun 09 06:23:01 2020 +0200 @@ -192,16 +192,25 @@ tmp_file_path = Path(request.content.name) request.content = None + # the 2 following headers are not standard, but useful in the context of file + # sharing with HTTP Upload: first one allow uploaded to specify the path + # and second one will disable public exposure of the file through HTTP + path = request.getHeader("Xmpp-File-Path") or "/uploads" + if request.getHeader("Xmpp-File-No-Http") is not None: + public_id = None + else: + public_id = upload_id + file_data = { "name": unquote(upload_request.filename), "mime_type": upload_request.content_type, "size": upload_request.size, - "path": "/uploads" + "path": path } await request.file_sharing.registerReceivedFile( client, upload_request.from_, file_data, tmp_file_path, - public_id=upload_id, + public_id=public_id, ) request.setResponseCode(http.CREATED)