Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

downloading files through web app  RSS feed

 
supriya lal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am building a web app where any one can upload a file. The file is being successfully stored on my computer but now i want everyone to get access to the uploaded file and can download them. I am completely new to this .Kindly help
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In pseudo code
1) set the proper response content type depending on the file type you are serving
2) Obtain the response print write
3) Set the proper response header e.g.
4) Obtain an input stream to the file to serve
5) Start reading the file
6) Write the read data to the output stream
7) Repeat till EOF
8) Flush and close

In case you run into trouble, show us what you tried, tell us where you are stuck and we will help point you in the right direction
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Maneesh said above is when you want to stream the file to client. This works for any file, but you may face problems if the file is huge (few Gb).
If you have the file in the publicly visible folder of the web app, you can display the file as a link on your page.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!