diff --git a/docs/events/index.rst b/docs/events/index.rst index 224656b3f..fe24e847f 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -197,12 +197,15 @@ File handling ------------- Upload - A file has been uploaded through the web interface. + A file has been uploaded through the :ref:`REST API `. Payload: * ``name``: the file's name * ``path``: the file's path within its storage location * ``target``: the target storage location to which the file was uploaded, either ``local`` or ``sdcard`` + * ``select``: whether the file will immediately be selected, as requested on the API by the corresponding parameter + * ``print``: whether the file will immediately start printing, as requested on the API by the corresponding parameter + * ``userdata``: optional ``userdata`` if provided on the API, will only be present if supplied in the upload request .. deprecated:: 1.3.0 diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index 78641dd36..06d2173a0 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -425,9 +425,14 @@ def uploadGcodeFile(target): if isinstance(filename, tuple): filename, sdFilename = filename - eventManager.fire(Events.UPLOAD, {"name": futureFilename, - "path": filename, - "target": target}) + payload = dict(name=futureFilename, + path=filename, + target=target, + select=selectAfterUpload, + print=printAfterSelect) + if userdata is not None: + payload["userdata"] = userdata + eventManager.fire(Events.UPLOAD, payload) files = {} location = url_for(".readGcodeFile", target=FileDestinations.LOCAL, filename=filename, _external=True)