Download link to file saved in BLOB type in database

Hi all,
I have made a page where i am letting users upload a file in any format, and i'm saving it to database in BLOB datatype field of a table.
The filetype is also saved in a different column of the table.
Now I want to retrieve the contents back in that particular format by converting the data in BLOB type to filetype.
And a link should be provided to download the file.
A little help can be taken from this link which uses EJB session to do the same thing.
[http://jdev1013.blogspot.com.au/2009/08/file-upload-and-download-in-toplink-adf.html]
I want to do the same in ADF 11g JDeveloper using Oracle XE database connection.
Below is the code i used to upload file data - now i want to download file data -
public String uploadFile() {
String amDef = "cabinet.model.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
ViewObject vo1 = am.findViewObject("XfileView1");
Row row = vo1.createRow();
if (uploadedFile.getFilename() != null){       
byte[] array=new byte[(int)uploadedFile.getLength()];
row.setAttribute("FileName", uploadedFile.getFilename());
row.setAttribute("FileContent",createBlobDomain(uploadedFile));
row.setAttribute("FileType", uploadedFile.getContentType());
row.setAttribute("FileSize", uploadedFile.getLength());
vo1.insertRow(row);
am.getTransaction().commit();
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItteratorBindings =
bindings.findIteratorBinding("XfileView1Iterator");
dcItteratorBindings.refresh(1);
Configuration.releaseRootApplicationModule(am, true);
return "added";
private BlobDomain createBlobDomain(UploadedFile file)
// init the internal variables
InputStream in = null;
BlobDomain blobDomain = null;
OutputStream out = null;
try
// Get the input stream representing the data from the client
in = file.getInputStream();
// create the BlobDomain datatype to store the data in the db
blobDomain = new BlobDomain();
// get the outputStream for hte BlobDomain
out = blobDomain.getBinaryOutputStream();
IOUtils.copy(in, out);
catch (IOException e)
e.printStackTrace();
catch (SQLException e)
e.fillInStackTrace();
// return the filled BlobDomain
return blobDomain;
Thanks
Cheena Malhotra

Check my 3 part blog about this. This should cover your needs. http://wp.me/pcBZk-aU
Timo

Similar Messages

  • Refcursor returning image (BLOB type) from database

    Hi,
    Process : Invoke activity takes ID as input parameter and passes it to partner link (db adapter) which executes stored proc returning a ref cursor. SQL statement in stored proc - ref cursor has a column with BLOB type.
    Problem : Unable to return an image (defiined as BLOB type in database) through refcursor in BPEL.
    Error : Unable to convert XSD element Column whose JDBC type is BLOB to a corresponding XML document element.
    ORABPEL-11087
    XSD :
    <complexType name="RowSet">
    <sequence>
    <element name="Row" minOccurs="0" maxOccurs="unbounded" nillable="true">
    <complexType>
    <sequence>
    <element name="Column" maxOccurs="unbounded" nillable="true">
    <complexType>
    <simpleContent>
    <extension base="string">
    <attribute name="name" type="string" use="required"/>
    <attribute name="sqltype" type="string" use="required"/>
    </extension>
    </simpleContent>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    Need Solution : To get an image (of BLOB type) into BPEL using ref cursor.
    Please let me know if you need any more information to get it working.
    Thanks and Regards,
    Rakesh

    Hi Rakesh,
    There are some notes you might want to refer :
    Note.423909.1      'java.lang.NumberFormatException' Signaled When Using Oracle LOB Family Column Types In ODI Datastores And Integration Interfaces:
         Note.423982.1      An "ORA-17410 No More Data to Read From Socket" Error Has Been Signaled From An ODI (Sunopsis) Integration Interface:
         Note.423768.1      Using Oracle Large Object (LOB) Datatype Columns In ODI Integration Interfaces:
         Note.744101.1      ORA-22835 Message Signaled When Using The OdiSqlUnload Tool In ODI:
         Note.424658.1      "ORA-00942" Message With Oracle Large Object (LOB) Datatype Fields In ODI Integration Interfaces:
         Note.423992.1      Using Oracle LONG Datatype Columns In ODI(Sunopsis):
         Note.424107.1      ODI Integration Interfaces And The Use Of Oracle Spatial Datatypes In Source And Target Datastores:
    Hope this helps!
    Cheers
    Anirudh Pucha

  • Uploading the file as a blob to oracle database

    Hi..I wrote a program to upload the files as a blob to the database. It works fine for JSP files but when i try to upload a css file...it gives "No more data to read from socket" exception. I have tried all combinations like trying to upload css file first and then a jsp file and then multiple jsp file and then a css file and so on, thinking that it might be a storage problem. But it gives an error only for the css files...could there be any delimiter kind of symbol or something in the css file which make the oracle think that it is the end of file? Just a guess...any help is appreciated...
    n btw i upload the file using the file input stream and then i use preparedStatement.setBinaryStream method ....
    TIA

    Damn it...I cant believe that i took this long to figure it out...the maximum size of the file that my blob can store is 4 kb...and all my css files are bigger than that...wasted so many hours on this...:(

  • How to display .doc/.xls file uploaded using blob type of column in table.

    Hi,
    Here
    http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm
    I learnt about uploading & viewing file through BLOB in a form or report . It works fine for pictures & notepad file. But when i upload word file (i.e. *.doc) or excel file ( *.xls ) , and try to view it through DOWNLOAD
    it gives message box
    ' Do you want to save this file, or find program online to open it?'
    I searched lot but enable to find proper & easy to understand solution.
    Hope understand my problem.
    Thanks in advance.

    Hi,
    I am using table emp having fields id,name,,,,,,,,,photo,mimetype,filename,last_update_date.
    photo is of type BLOB. I updated photo (text item) on form.
    I Used BLOB DOWNLOAD Format Mask with appropriate entries & selected display as Attachment.
    So my problem is partially solved. Now if DOWNLOAD link on Form is clicked it displays Excel sheet
    in different window. But still, DOWNLOAD link on my Interactive report not working properly.
    DOWLOAD on interactive if it is clicked it has two problems
    1) It opens image or notepad file in same window.
    2) Not able to open Excel sheet.
    thanks for reply.

  • How to display binary file saved in BLOB column in Discoverer PLUS /VIEWER

    HI, Friends,
    I tried to display the binary file saved in the database in BLOB column with the *.doc or *.xls fomats, but it seemed not work at all. I can display them in discoverer DESKTOP, but not the web version PLUS or VIEWER. MY Discoverer PLUS/VIEWER version is 9.0.4.45.02 and the database is 9.2.0.4. Are there any special setting/configuration in somewhere (Discoverer administration/Applicaiton server/PLUS/VIEWER?)
    Any help /information will be greatly appreciated.
    Thanks a lot.

    Hi,
    Sorry but this feature is not available in the web version of 9.0.4.45. You will have to write your own mod_plsql function to download the file.
    Rod West

  • Downloading a pdf file, saving it, won't show the full name of the saving file when the name contains a space, stopping the file name.

    Downloading a pdf file, the name of the file contains a space in the middle of the file. The name showing on the 'Save' popup is the first few letters up to the space. Works fine on IE8. For instance, a file named "old snail_12345.pdf" would only show "old" (ignore the "s). This is on Firefox 30.0, WinXP Pro.

    Is this a problem when you are viewing the file in Firefox's built-in PDF Viewer and using its download button, or when you are using a download button in a web page?
    I've seen this problem occur when the server is pushing a different file name than the actual file name (for example, the file name is pdf.asp?id=12345 but the server is sending the name Annual Report.pdf in the headers sent with the file). I'm not aware of a workaround for the user, but for what it's worth, it is easy to fix on the server by replacing the spaces with %20 (the standard substitution used in web addresses).

  • Html db to display pdf files saved as blob in the data base

    Hi all,
    I have a DB page to call next page to display pdf files.
    A procedure is being called when the link is clicked on the first page.
    However, the procedure output a juck code insteand the pdf files. Please help.
    Thanks,
    n_length number;
    n_image BLOB;
    begin
    select note_image, dbms_lob.getlength(note_image)
    into n_image, n_length
    from n100_notes where note_id = nid;
    owa_util.mime_header('application/pdf');
    htp.p('Content-length: ' || n_length);
    wpg_docload.download_file(note_image );

    we use:
    owa_util.mime_header('application/pdf',false);
    htp.p('Content-Length: ' || dbms_lob.getlength(l_blob));
    owa_util.http_header_close;
    wpg_docload.download_file(l_blob);
    see plpdf.com
    LL

  • Download Word .doc file saved in MIME Repository to local PC

    I need to store a static Word document on the SAP server and download to the user's browser via a BSP application.  I have found code in the IT00 BSP Application to download the Word doc in xstring form to the browser, which will work for what I'm doing.  What I cannot seem to find, however, is how to retrieve the  Word .doc file stored in the MIME repository and then subsequently how to convert this MIME object to an xstring value.  Is there a class or function module available to retrieve and convert the MIME object to an xstring form so that it can be returned as a response back to the browser?

    you can use the following code snippet to read mime repository content.
    data: o_mr_api type ref to if_mr_api.
    if o_mr_api is initial.
    o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).
    endif.
    call method o_mr_api->get
    exporting
    i_url = l_url
    importing
    e_is_folder = is_folder
    e_content = l_current
    e_loio = l_loio
    exceptions
    parameter_missing = 1
    error_occured = 2
    not_found = 3
    permission_failure = 4
    others = 5.
    l_current will hold the image in a XSTRING var
    Regards
    Raja

  • Create download link to file in KM

    Hi,
    In our portal I have configured a couple of KM iViews (on KM repositories) for anonymous access. Works fine.
    Now I would like to create a URL to a file in 1 of those repositories. The purpose is that when a user enters that URL in a browser, he/she will be asked if they want to download the file or not.
    Does anyone knows if it is possible to generate such a URL?
    Under Details -> Settings -> Properties -> Access of a file, there is a target URL. This URL works, but it opens the  file for me and doesn't give the option to download it.
    Regards
    Edmond

    The KM HTTP servlet supports that, but you need to build a different URI.
    As far as I recall, for a KM doc such as
    http://server/irj/go/km/docs/repository/test.doc
    the URI would be
    http://server/irj/go/km/docs?action=download&URI=/irj/go/km/docs/repository/test.doc
    (this is what you get when you choose "download" from the KM UI).

  • How to store file content in BLOB field MySql database using java

    Hi!
    i want to store the file content in a BLOB field in MySql database using java.
    Please help me out..........
    thanx in advance...
    bye

    i stored images in db, and retrieved them. like that cant i store pdf file in db, and retrieve it back using oracle db?
    Plz help me out how to put a file in db. i need complete code. thanks in advance.

  • Displaying a word file stored as BLOB in the database

    Post Author: Sathish K Sekar
    CA Forum: WebIntelligence Reporting
    Hi,
    Is it possible for us to display a word file which is stored as a BLOB object in  our database.
    We are using BO XIR2.
    Thanks in advance
    Sathish

    Post Author: InfluentialSoftware
    CA Forum: WebIntelligence Reporting
    Sathish - is this query specific to wanting to display a Word file or does it relate to how to display any BLOB objects in the database via Infoview?Thanks,Andy 

  • Forms 6i - display into image item picture stored in blob type on database

    hi to all
    i searched on this forum but in don't found solution my problem.
    I created table with a column blob and i design form that insert and display image stored in database ( oracle 9i )
    i used image item type with block database based
    my version forms is
    Forms [32 Bit] Version 6.0.8.13.0 (Production)
    if i define column table like "long raw" it worked but i used blob i insert but i don't display image
    error is:
    ORA-00932: inconsistent datatypes: expected got
    thanks a lot to all
    bye

    I know, that the false forms-version (patch) gives you this errors. Try a newer patchset. For example patch 13-15 (for 9i), or 17 (10g rel. 1)

  • Download an uploaded file

    Hello everyone.
    I've been working with SAP HANA for almost 2 months so I'm still learning it.
    I made a file uploader in a page  with SAPUI5 file uploader, witch is working just fine.
    But now I have to allow the user to download that file, and I do not know how to do it.
    I save the file in a blob type into the database with its mime_type. I am trying to see the blob content but it returns a [object ArrayBuffer]
    How Am I suppose to make that file to be downloaded? 

    I've found out the solution.
    I was setting a blob colum with setString() function at the prepare Statement instead of setBlob.
    then
    $.response.contentType = result[0].mime_type;
    $.response.status = $.net.http.OK;
    $.response.setBody(result[0].conteudo);

  • Link to files

    Will InDesign CC be able to link to files saved in the Cloud?

    You simply have to save files on your desktop and upload them on to the cloud, later with Cretive Cloud Connection / Folder you shall be able to do it.
    Cheers
    LP

  • When I try to click on a download link for a .pdf file Firefox does not recognize the MIME type and tries to download the file as "index.php"

    When visiting a site I frequent I tried to download a linked .pdf file. Previously I've used Firefox 7.0.1 to download the link with no problem. Using Firefox 8 however I the browser does not recognize the .pdf link's mime type. Instead of recognizing the download link as a .pdf file Firefox 8 tries to download it as "index.php". Firefox 8 does this with .doc files and .txt files as well. When I downgrade to 7.0.1 again the problem disappears.

    Hi hakmacpace,
    I'd try starting Firefox in [[Safe Mode]]. If you don't have the issue while all of your add-ons, extensions, and themes are disabled, you can try adding them back in one by one until you find the culprit. You should look at the [https://support.mozilla.org/en-US/kb/Troubleshooting-extensions-themes Extensions and Themes troubleshooting guide ] and the [[Troubleshooting plugins]] article as well.
    You could also try [https://support.mozilla.org/en-US/kb/Managing-profiles?s=create+a+new+profile&r=2&e=es&as=s#w_creating-a-profile Creating a new profile].
    Hopefully this helps!

Maybe you are looking for

  • How to use a stored procedure as a datasource in Crystal Report for Eclipse

    Hi All, I've written a stored procedure in oracle 10g with few input parameters and one refcursor output parameter. I want to use this stored procedure as a data source for creating a report in "Crystal Report For Eclipse 3.6.0". When I tried to add

  • Tags that end but dont

    In my custom tag library, I have an HTML tag that will write out HTML along with any attributes it is passed: <tl:HTML name="img">   <tl:HTMLattribute name="src" value="myImg.gif"/> </tl:HTML>I do that by extending BodyTagSupport and not writing the

  • What's going on with my recent iTunes purchase?

    I bought the Dark Knight Trilogy on iTunes last night and the films showed up in my library and I was able to stream them without issue. However, today they're not in my library on my Mac or my iPhone, nor do they show up under the "purchased" sectio

  • Change Dictionary Entry on N95

    Some how, whilst texting I must have managed to miss-spell "you" and tell the N95 that its "yot". Making yot the pretictive default for "you" Can I remove "yot" from the dictionary or reset the predictive text back to factory settings as a last resor

  • Stuck in a restart loop

    Hi guys, finally ditched the pc and bought a mac mini duo core! Problem is the first thing I done was download the software updates and then install them. The OS told me to restart my machine which I did but now when it boots up it comes up with a me