I'm working in a node JS REST service. All the endpoints are almost done.
I have created a simple web page where the user can introduce a .gpx file (xml) and with the module xml2json convert it into json format.
I have tried the function using a local path and works, but my problem comes when I deploy the application into a web service, Javascript can not take the local file path to convert the file and store the JSON into the database.
I don't know how to proceed. Should I upload the file into my server and after that take the server path and converse the file? ( I donĀ“t need the file so should I delete after the conversion?)
Could I converse the file without upload to the server?
Help me please with some clues to proceed.
Thank you all in advance!
Related
For my college project, I'm developing an application that analyzes/detects anomalies in videos.
The backend is Python and the frontend is JS/NodeJS. I setup the backend so it runs 4 ML models and writes the outputs to 4 separate .txt files. I created a JS file that reads the .txt files and reformats the data to be saved as 4 .json files. Currently, the frontend just reads the .json files and displays the data... I run npm start to display the application in the browser at localhost:3000. Here is my problem:
In the application, the user can upload a .mp4 file and watch the video (react-player). I think I can setup a button interaction to execute a script that runs the backend .py file. However, I don't know how to continue from there. I need to exchange data twice: First, I need to download the video to the .py file local directory as input to the ML models. Once the models have finished running, I need to
transfer the outputs (Python list or .json format... I know how to do either) back to the application so it can be displayed to the user.
I'm reading online that I can execute data transfer using jquery and/or ajax calls? Or maybe I setup a database? I have 0 experience w/ any of that so I'd like advice on the easiest approach. If you can recommend resources that can help me learn more on the topic, that'd also be helpful.
You can use WebSocket to transfer the files, initially after sending the video to the backend there would be quite a bit of delay for the ML model to process it and come up with the output JSON files, WebSocket would make it easier to make this communication.
(I'm not saying it's not possible to use a rest API to do the same, but it would be easier to use WebSockets)
Recently, I found that there is called 'LowDB' and it can control the json file with NodeJS.
Actually, I can use MySQL or other databases but I think the App that I developing now is small application so it needs very tiny DB like simple Json.
This Link is connected to lowDB example.
Link
https://github.com/typicode/lowdb
As you can see it controls json file and it includes CRUD(Create, Read, Update, Delete) function. But the data are save in Local storage not in server. So Even I control the json files it will only apply in Local Json file. I want to save it in server.
How can I manage json file with NodeJS? Please give me some keywords or introduce some Node Dependencies.
First off, I know this seems illogical when I could just send the download URL to the server. The issue with that is that user's can access these download links and so for those who can I need to be able to download it. I can't really explain why as I am under NDA.
I am trying to download a file from a URL via the client (browser) and stream the data directly to the server where the file is saved so the client essentially acts as a "middleman" and does not require the file to be downloaded to the client's machine.
I have been experimenting with "socket.io-stream" and "socket.io-file" but i am having a few issues with both. "socket.io-stream" allows me to upload a specific file from the client to the server but the uploaded file has a size of 0kb and doesn't have any examples on Github.
"socket.io-file" has examples, which I followed and currently have it setup so I can use an input tag to select a file to upload to the server successfully.
From what I can see the "socket.io-file" upload function takes a file object as the parameter.
So I have two questions really:
Is there a plugin for JS (Browser) & NodeJs (Server) that would allow me to do this?
or
How can I create a File Object from an external url?
I solved this is the end, using a chrome extension to download the file as a blob object, pass the object to the content script and then use socket.io-stream to upload it to the server.
So I am working on a webpage (hosted on github pages) where I need to convert the data entered by the user to a json object and then saving it to a file on the github repo for later use.
So far, I've converted the data to a json object, but I'm facing difficulty in storing this object to a .json file in my github repository.
Any suggestions on this would be appreciated.
Cheers.
As MAttds17 said you will need a server side.
If your code will be simple, you can use a Backend as a service like Firebase or Backand.
If you think you will have heavy logic in your server side, you can host a real application in Heroku or another alternative.
I'm making an application in the express framework where the user uploads a zip file and views it on the website. I already have uploading a single html file and viewing it; however, I can't seem to figure out extracting a zip file online. I can currently store the zip file in the database, but when it's pulled from the database it seems to be impossible to unzip it in to the url and not on my disk. Where do you think I should start with trying to solve this problem?
I suggest the use of this module: https://github.com/cthackers/adm-zip - I have succeded in using it when user uploads file that must be unziped at server side. I think that docs for the native zlib API are missing or not yet supplied. Let me know if this helps
Not sure which zip format you're using, but one example of how it could work is with the zlib api: http://nodejs.org/api/zlib.html
If you use that library to create a stream you can write that stream to the response, in concept. The bigger question in my mind is what do you mean by "unzip to a url"? If the zip is an archive w/ multiple files, what do you expect a user to see at that URL?