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?
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.