diff --git a/sat/plugins/plugin_comp_file_sharing.py b/sat/plugins/plugin_comp_file_sharing.py index 3577f89a..66c8f4dc 100644 --- a/sat/plugins/plugin_comp_file_sharing.py +++ b/sat/plugins/plugin_comp_file_sharing.py @@ -192,16 +192,25 @@ class HTTPFileServer(resource.Resource): 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)