What File to Edit to allow for more extension uploads?

what file can I update to allow other files to be uploaded through the interface? STL / OBJ / CURAFILES

What is the problem?

Cant upload original stl files

What did you already try to solve it?

None

Have you tried running in safe mode and if so did it solve the issue?

No

Complete Logs

Could not upload the file. Make sure that it is a readable, valid file with one of these extensions: .g, .gco, .gcode

Editing files to change things like this is not usually possible, since it is probably in the source code somewhere.
Try the 'Upload Anything' plugin:

My question here would be: Why? What do you plan to achieve? You cannot do anything from OctoPrint with any other file types than the ones already supported, unless you also install a slicer plugin, or some other plugin that knows what to do with further file types, in which case those plugins already do add support for the additional files.

This question sounds like someone is asking how to solve a problem they think they are having, when in fact they have a different problem.

The why is so simple. You ever use thingiverse? In there people save recipes in the zip file with the stl or they save pictures. I want to add my original stl files to the folder where I have my gcode files so if I ever use it on another printer or filament I can just go to octo and grab it.

In that case, the aforementioned plugin would help you.

We've had people come on here, asking how to upload STLs to OctoPrint because they expected to be able to directly print them without the slicing step in between, and then were upset when that didn't work as they expected and vented their frustration at us, so I hope you understand why I asked for the motivation behind this question.

Oh lol I understand 100%. I added the plug-in then forgot about it so fast.

I just retrained myself to store on a cloud provider and used a plug-in for cura or slic3r to just upload and start printing immediately and use octo as a temporal area.

I’ve been going through printers or nozzle sizes so fast I just do thing locally now.

Don't like to resurrect, but is there a specific reason that not all the variants for gcode are accepted by octoprint?

My slicer outputs ".gc" variant, and while it is simple to edit the file type manually, it is getting really old. I am already in contact with the author of the slicer about the fact that I cannot change the file type in the export process.

I don't think I've seen .gc on a file before - and a quick google search shows it conflicts with several other file types. In this case, you could use the plugin noted above to allow you to accept this rather specific file type.

I guess when I had installed it the first time, it did not load properly. After disable/enable it is working and I was able to add .gc, now to see if it will understand that it is a gcode file.

@foosel, my apologies for practicing necromancy but I've got a legit use case, or so I believe.

Please support the uploading of .gc files. Certain gcode generators for certain gcode devices save their gcode, by default, with the .gc extension.

I'd like to be able to add this behavior to a plugin I maintain as my use case is specific to a certain type of gcode files, but I'd be perfectly good with a universal option as well.

here's how I solved this in a plugin I manage:

    global __plugin_hooks__
    __plugin_hooks__ = \
        {'octoprint.plugin.softwareupdate.check_config': __plugin_implementation__.get_update_information,
         "octoprint.filemanager.extension_tree": __plugin_implementation__.get_extension_tree}
    def get_extension_tree(self, *args, **kwargs):
    		return dict(
    			model=dict(
    				grbl_gcode=["gc", "nc"]
    			)
    		)

class xxxPlugin(...octoprint.plugin.EventHandlerPlugin,...):

    def on_event(self, event, payload):
        # File uploaded
        if event == Events.UPLOAD:
            if payload["path"].endswith(".gc") or payload["path"].endswith(".nc"):
                uploaded_file = self._settings.global_get_basefolder("uploads") + '/' + payload["path"]
                renamed_file = uploaded_file[:len(uploaded_file) - 2] + "gcode"

                self._logger.debug("renaming [%s] to [%s]", uploaded_file, renamed_file)
                os.rename(uploaded_file, renamed_file)

It would be nice if we could manage gcode as if it were a mime-type.... one that we could config via settings or similar.

You could probably use self._file_manager.move_file instead of directly doing it in the OS, or you risk OctoPrint's file metadata/analysis being confused. Although I'm not sure if it would change anything or even work if OctoPrint doesn't recognize the file to start with.

https://docs.octoprint.org/en/master/modules/filemanager.html#octoprint.filemanager.storage.LocalFileStorage.move_file

I thought about that too.... i definitely put this in my hacks category of tricks.

For my specific use case I have model size detection disabled. The rename is also picked up instantly by octoprint so imagine there is an inotify or similar watcher in place.

I messed around briefly looking for the filemanager namespace / class. Thanks for the link. I'll be sure to use it instead of the os.rename operation.

I think there's something wonky with the docs for that, since it's not linked from the injected properties page when all the rest of them are.