downloading file vs creating file on client side javascript - javascript

requirement - download a particular file on user action .
We can create files on client side using FILE API. So I am creating a file on client side from the data which is received from server so that user can download the file .
There is one more approach to do this that is getting file generated at server side and getting URL to the file instead of sending the file data.
I want to know which approach is better in terms of security and performance ? sending file data from server or sending a file URL from server?

Related

How to post a file to localhost without breaking it apart? (using ajax/jquery)

I'm now trying to send a json text file from my index.html to a localhost server.
I've read a lot about this topic and I know I can use multipart/formdata to break a file into scraps -> send to server via http -> append them back at server side.
But what if I just want to send a text file with a small size? (btw I don't want to read the file at client side. I want to send the whole file) Is that doable?

Can I create a directory in client PC?

I have multiple questions
Can we create a directory in client machine ?
Can we check the running browser's default download path?
My requirement is that the user will download a BLOB data from my DB that time I want to create a folder in client machine and use that folder to save the blob data.
Can this be done using javascript,jquery,ajax,php,angularjs ?
You can't create a folder in client PC using JS.(don't even bother looking with HTML and CSS)
The best way you could accomplish something as you describe is to give a .zip to your client, so while extracting it, it creates his own container (the folder). But you must be sure that the people who intend using your web application knows how a .zip works.
Using PHP you can't do anything in the client PC. PHP is a server side programming language. So, it is running only in the server. When you make any request to the server then only PHP performs. In the browser end or client side only HTML, CSS and JS works.

Javascript to let webserver fetch range-like requests of data from a large file on client PC?

When uploading a large file to a web server for processing, the upload itself can take a long time, and unless the file can be processed sequentially, the server has to wait until the entire file has been received before processing can begin.
Is it possible to make some javascript "glue" that lets the web server request specific ranges of data from a file on the client's computer as necessary? What I'm asking for is in a way the same as HTTP Range capability, only the server would be generating the requests and javascript on the client computer would be serving the data.
By doing this, the web server could process files as they're being uploaded, for example video files with important information in the footer, or compressed archives. The web server could unpack parts of a zip file without uploading the whole archive, and could even check that the zip file structure is correct before a large file is uploaded. In fact, any generic processing of a large file that can't be read sequentially could be done at the same time as the file is being transferred, instead of first uploading the file and then processing it later. Is it possible to do something like this from the browser without deploying something like java or flash?
If it's possible to read bytes as necessary from the file, it's also conceivable that the web server wouldn't need to have space to store the entire file on a local drive, but simply access the file directly from the client's drive and process it in memory. This would probably be inefficient for some use cases, but the possibility is interesting.

Ajax upload a file from browser to FTP server

Is it possible to uplaod a file from browser to FTP server using ajax?
No. Browsers provide no APIs that allow writing to FTP from JavaScript.
You could post the file to an HTTP end point and then use server side code to push it to your FTP server.

implementing server-side after REQUEST sent

Right now, i found out that if i were to put this url to my browser, a .csv file will be downloaded to my Downloads folder on My Computer, where the word YHOO is the stock symbol of Yahoo
http://ichart.finance.yahoo.com/table.csv?s=YHOO&d=0&e=28&f=2010&g=d&a=3&b=12&c=1996&ignore=.csv
Is there any way where I can implement the above action on my own personal-use RESTful website where
on a client-side GUI, the user inputs symbol
on client-side, a request URL is constructed with the symbol
client-side sends the request URL to the browser (similar to the action i described above)
browser downloads a file to a location on a server (dropbox / EC2)
.csv file is converted to json object on server
json object is returned to client
How can i do this, and which framework is recommended for high performance. i am thinking of NodeJS and Mongoose.
I'm interpreting your question like this:
on a browser or GUI, the user inputs symbol
on server-side, a request URL is constructed with the symbol
server-side sends the request URL to the above url (similar to the action i described above)
server-side downloads a file to a location on the server or remote repository(dropbox / EC2)
.csv file is converted to a json object on the server
the server then returns the json object is returned to the browser or GUI
If so, then the answer to your question is yes, this is possible albeit a bit tricky if you want to to work properly.
This doesn't have to be Node.js specific. You don't need Node.js nor Mongoose for this since you're not saving the CSV to the harddrive but just going to be an interrim transporter.
Basically you can in your "servlet" issue a POST call to another url and fetch the CSV file.
Then convert this and write the file on the response and serve it back to the client.

Categories

Resources