Categories
3D Printing Octoprint

Octoprint Shared Folder

After I uploaded this to the r/octoprint subreddit user u/ahoeben commented that sending files directly to the uploads folder is bad practice as Octoprint will not analyse the new files and you’ll get errors

Normally when you upload a file through the OctoPrint interface, or through a client, OctoPrint knows about the new file and starts analysis of the file when the upload is complete. When you upload through other means, OctoPrint does not notice there is a new file, and the file does not get analysed. This not only means that OctoPrint does not get to check if the print fits within the configured build volume and similar checks, but it also means that plugins like PrintTimeGenius simply won’t work because they rely on more extensive analysis of the gcode to happen after upload.

u/ahoeben

I tested this by uploading to the watched folder instead and, after a moment, the gcode file was moved to the uploads folder and the .metadata.json file the uploads folder was updated with the analysis of the gcode I had just uploaded. The only downside is that the file was moved to the root of the uploads folder. I tried creating a folder inside the watched directory and dropping my gcode inside that new folder but Octoprint was unable to scan the new folder and its contents and so it just sat there.

I’ll update this post if I find a fix for this. Until that time, feel free to play with this but know that Octoprint will not be able to analyse your gcode before printing and that may break some things. I will note that I have not had any major issues printing this way but have gotten error messages before I started a print. After printing, the metadata is updated and subsequent prints kick off without error.

To make managing my gcode on my Octoprint server easier I have setup Samba and shared the uploads folder over my home network. Follow along if you want to do likewise.

First up, let’s ssh into the Octoprint server. The default password is raspberry.

ssh pi@IP.OF.OCTO.PRINT

Now we need to update the package manager and install Samba. The first time you use sudo will ask for a password. This is the same password you logged in with. You won’t need to re-enter the password for the next commands unless you wait longer than 15 minutes between commands…

sudo apt update
sudo apt install samba

To share the folder we’ll need to edit Samba’s config file. I use nano as my preferred editor however use the editor of your choice.

nano /etc/samba/smb.conf

Scroll to the bottom of the file and add the following lines.

[gcode folder]
  comment = gcode upload file
  path = /home/pi/.octoprint/uploads
  read only = no
  browseable = yes

You can put whatever you want inside the brackets [ ]. This will be the name of the folder you’ll see from your computer later.

I also commented out the Home Directories section to keep the home directory from showing up as a shared folder. Even though it’s only shared as read only I still don’t see a reason to share it if I’m not going to use it.

Scroll up from the bottom of the file until you see [homes]. Comment out the following lines by adding a # or ; at the beginning of each of the following lines.

;[homes]
;  comment = Home Directories
;  browseable = no
;  read only = yes
;  create mask = 0700
;  directory mask = 0700
;  valid users = %S

After we’re finished editing the conf file press Ctrl+X to save the file. Press Y to confirm the changes and then press enter.

Now we need to add a Samba user to access the shared folder. The password can be anything you want.

sudo smbpasswd -a pi

Finally we need to restart the samba server for our changes to take place.

sudo service smbd restart

We can now access the shared folder from our computer. Press Ctrl+r to open the run command and type in: \\IP.OF.OCTO.PRINT

You’ll be asked for a username and password. The username is “pi” (without the quotes of course) and the password is the password you set during the smbpasswd command.

Now you can manage your gcode files without having to upload each individual file via the Octoprint web interface.

I know there are plugins to help manage your files but I prefer this method.

2 replies on “Octoprint Shared Folder”

Thanks! I had to `sudo vim /etc/samba/smb.conf` and my home was already not browseable. Great guide, thank you for publishing it!

Leave a Reply

Your email address will not be published. Required fields are marked *