Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

File Upload + Destination directory.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I am developing a web application using the Struts framework. I have a page where I am using html 'file' controls to attach/ upload files.

1) Upload part:
---------------
I receive these attached files in the Struts action/ task and use struts upload's FormFile class and it's getInputStream() to read the file contents.

2) Storage:
-----------
I use JBOSS as my application server. In my case, the uploaded files are written/stored in a directory (/usr/loca/data in Linux) outside the app server's context. As a part of this process, I store the name of the file in the DB so that I can refer it later.

3) Retrieval:
-------------
When these files, for example, .jpg's are requested as a part of a picture gallery I refer the DB and get all the image names associated with the gallery.
(3b) I then move the respective image files from the directory (step 2) to the app server's context.

My question is 3 and 3b a scalable approach. My application will have more and more files (images, pdf's et...) attached in the future. I think the process of moving files as I do in step 3 will be a major efficiency problem in terms of space and size (the .war file i generate after having the files moved inside is HUUUGE).

I am sure I am missing something when it comes to file upload, storage and retrieval. I do not understand the concept of how/ where these files are stored in the first place.

Please let me know if you have any ideas on how it can be implemented/ improved.

Thank you,
Karthik.
 
Karthik Muthukumaraswamy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a correction to my initial post:
----------------------------------------
In step 3 I DO NOT move the files from the directory in step 2 to a directory inside the application's .war file. Instead, I am copying these image files from directory in step 2 into a new directory that I create inside the EXTRACTED .war file (As I mentioned in my previous post, I am using JBOSS and it extracts the .war file when we deploy it)


-Karthik.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it would be better to store the files in Db as blob rather than in a file system. And when the user queries retrive those and show it to the user.

Regards,
Arul.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this link : http://struts.apache.org/2.x/docs/handling-file-uploads.html

Try it out...
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic