Upload file using API by local file path - JavaScript "Nodejs"


#1

Hi

What I want is to upload a local file "On machine disk" to the Octoprint API
When I checked this URL I was confused Wher I can pass the local path for the file that I want to Upload
http://docs.octoprint.org/en/master/api/files.html

Then I saw
http://docs.octoprint.org/en/master/jsclientlib/files.html#OctoPrintClient.files.upload
And Also I confused if I can use this in my node js app and if yes How I can import pre-implemented JS API

So if someone can help me to on how I can upload I file using a file path

Thank you


#2

You could have used the search feature here for "api upload javascript" which would have taken you to this thread.


#3

I saw this thread
But mu problem is
form.append("file", $(file_input)[0].files[0]);

I am running JS as tool to control the printer
Not on web

So how I can pass the file with file path on my machine


#4

Unfortunately if you search the Internet for how to upload a file using NodeJS you're likely just going to get yet another tutorial on how to build a server which accepts a file upload from a form.

What you're looking for is how to upload a file using NodeJS as the client rather than as the server. If you know the right way of searching, you eventually find something. But no, I don't intend to code your project for you. You'll have to work at this, learn what you're doing and make something that you understand rather than copying/pasting.