I am new to Node.js ,with the help of this
tutorial I've learned how to write REST API using Node.js .Can anybody please help me to understand how to upload an image file using Node.js and saving it in mysql table ? I've been searching for it , but couldn't get something useful . Any help would be useful to me.
Typically files are uploaded as multipart form data from a web page. You could start there with a simple <input type="file"> on a web page.
Create an endpoint in Express, and consider a package to help parse it. One like express-formidable would be a good start. Then you will have the file from the request.
To save to mysql, I'd suggest the package knexjs. This is a nice library to programmatically write SQL queries. You'll have to define your own tables that store the image (probably as BLOBs) and you can use Knex to store the new images into your DB.
Be aware of the asynchronous flow in NodeJS. For your Express endpoints, you only want to finish the response after the DB code is done, like inside the knex call's callback (or at the final .then() of a promise chain)
Related
1) I have already made transformation mapping for getting data from specific MySQL (Table Input) and convert it as Text File output.
2) Also I have created a facebook developer account page and trying to figure out how the Facebook API works to push data from MYsql to facebook.
3) would appreciate if transformation mapping can be provided. Also I would not like to use XML, instead I would like to use JSON.
Already the msql table is converted to csv file, but I am not sure how to post the csv file to facebook or is there a way to connect mysql table to facebook directly. Please share your ideas or transformation mapping. Thanks
I would Assuemm you are familiar with Facebook Development API to do all actions like post,get and so on.
You have a step called "REST CLIENT STEP" in Pentaho.
you will have an API url to post the data that you want from mySQL. There several methods GET PUT POST DELETE
Also set the Application Format to Json (XML,JSON etc).
I used to read data from FB using REST Client by using GET Method. Work around.
I'm really wondering what's the correct and best-practice way for importing data from a json file in an ionic 2 project so I can show it in a template, for example.
Some solutions I can find use interfaces, some don't. Some implement own small services, some don't. Some use http.get().map().subscribe(), some just use subscribe(). I would really like to know how to do this properly and would be glad if somebody could enlighten me.
From my view the best practice is to use a service and use http get request to get json file from your server. We did the same for getting language json file.
If you want securely get json file then you should put your json file at secure folder rather than public folder and create an api to get json file or json object from server.
Hope it will help
I have a json file with information scrapped dayly from the web and as it's just a small array I decided to put it in a file in the public folder and read it client side. The array will be used as the options for a select tag.
I would like to read it only client side without pinging the server. How can I read the file in a template helper?
As I'm new to web development the file client side solution was the one I thought was best. If you believe there's a better way please state it and explain why is better. Thanks
You can use the http package to make a httprequest to the 'public' folder.
HTTP.get("yourweb/yourfile.json",{},function(error,result){
//do something with result
});
https://docs.meteor.com/api/http.html
I'm trying to create an HTML file to be uploaded to a different server from a Rails app. I need a solution similar to a mailer in Rails. Does anyone know of a feasible way to achieve this?
If you are trying to send a file between servers, the easiest way is to create an API endpoint on the other server that allows uploading a file and use an API key to secure the connection. You could very easily use an HTTP POST method to perform the transfer (https://rubygems.org/gems/httmultiparty). If you need to generate the file first:
data = render_to_string("post/show")
HTTParty.post('http://other.host/posts', contents: data)
I have a simple DataGrid that gets the Data from a JSON file hosted on a server.
I am using the build Data Connection Wizard and it works great.
Now I want to let the user manipulate the data and send it back to the JSON file.
I tried to add a form to the data grid but it changes only the data on the application and it is not influencing the file on the server.
any help or direction how should i do that will be appreciated.
Shani
Well i finally used
AMFphp and wrote my own functions.