File Creation / Upload / Download in Web Application

My actual file exists in database as blob object and i want give download access to client user without any copy on File System.
How can I do that?

Technology: Struts
Database: MySQL
pixarsolAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pareshprajapatiCommented:
Just query requested file content from database and get content in one variable.

Set page content-type header as per file type and print your file data read from database.

e.g. for pdf file output

// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
print($content_variable);

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Varghese JacobAssistant Project ManagerCommented:
For the above solution, you may need a PDF converter to convert the text to PDF format.

The easier solution would be to put the data in a variable
columns tab delimited
rows CR+LF delimited
header with "Content-Type" as "application/vnd.ms-excel;"
and "Content-Disposition" as "attachment;filename=some name.xls;"
0
Varghese JacobAssistant Project ManagerCommented:
How the actual file is put in the database? What is the type of data.
Based on these factors, you can modify the content type.
0
pareshprajapatiCommented:
You can use binary long object or Memo type of fields to store your files. If you are talking abount MySQL then as per file size you can select BLOB, MEDIUMBLOB or LONGBLOB.

Read file in one variable and insert whole content in such fields.
While downloading, as per file type set the header, read the content from database and just send read content to browser.

This should work for you.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.