Read SD Card GCode-Content during file selection

Hi,

I received an issue report that my plugin throws an exception during accesing the sd-card storage.

From technical point of view it is clear for me...but is there a way to read the file-content from the sd-card? How can I do this, is there a filemanager-methode that I can use?

Currently I am reading the file content during the file-selection event like this:

fileLocation = payload.get("origin")
selectedFilename = payload.get("path")

# full path on local file-storage
selectedFile = self._file_manager.path_on_disk(fileLocation, selectedFilename)

with io.open(selectedFile, "r", encoding="ISO-8859-1") as f:
   for line in f:
     #do somethng usefull with the line

If I try to read a file from sd-card I receive this message, after calling path_on_disk:

octoprint.filemanager.NoSuchStorage: No storage configured for destination sdcard

Any ideas?

Is that even possible? Can you download a file from sd card? Sorry I don't do too much SD card printing so don't have any experience with it, but I would just only react to events where payload.get("origin") == "local" personally because I don't think the speed would be quick enough reading from SD to be worthwhile dealing with even if it was possible.

There are no commands built into firmware that allow reading from the printer's SD card. Consider it a write-only interface.

Thx, a lot for the clarification!!
As @jneilliii suggested, in future I will check what kind of file I want to process -> only localfile.