Quantcast
Channel: Adobe Community : Popular Discussions - ColdFusion Server Administration
Viewing all articles
Browse latest Browse all 78799

problem using CF 9 to save uploaded PDFs into an Oracle 11g db as BLOB

$
0
0

We have a Coldfusion application that allows users to submit a form to us and attach PDFs to it.  The data is written to an Oracle database and the PDF is convereted to a BLOB using cffile actions and a cfquery  (code below)  We applied the last CF 9 hotfix when it came out in February 2013, and we upgraded our Oracle database from 11.2.0.1 to 11.2.03 at the beginning of March; at the same time we moved from a Virtuozzo virtual server to a VMWare virtual server.  OS on the database server is Windows 2008, on the web server it is Windows 2003 R2.

 

Sometime after the Oracle move & upgrade we noticed that many of the PDFs being submitted through the web application are being corrupted.  The Adobe Acrobat message just says 'There was an error opening this document.  The file is damaged and could not be repaired.'

 

What I've done to try and debug this:

 

Checked my BLOB size on Oracle- the max size is 119TB  and the PDFs are generally under 200KB so there should be pleanty of room for them.

Updated the maximum size of post data to 500,000MB and the request throttle memory to 750,000.  The February hotfix had set these numbers smaller, but making them bigger did not fix the problem.

Looked at various CF logs, there is nothing be reported as an error on submission of the data or when the link that gets the PDF from Oracle and displays it is clicked.

Used the code to write the PDF to a temp folder on my webserver- I am able to view it so the problem is happening somewhere between writing it to the webserver, inserting it into Oracle as a BLOB, and retrieving it from the database.

Looked at the BLOB field in the Oracle table using PL/SQL Developer (a WYSIWYG app for working with Oracle tables).  I can see that there is data in the BLOBs that are not displaying on the web, so at least I know that something is getting put into Oracle, but I do not know if it is corrupted in the table.

 

I'm not sure what to do next to pinpoint the problem.  Any help would be appreciated.  Below is the code used to submit the PDF, and the code to view it.

 

Many thanks!

Christina

 

 

------------------------------------------  rr.add.cfm

 

<cfif isDefined("FileName1") and trim(#FileName1#) neq "">

     <cftry>

      <!--- Upload the file to a folder on the webserver and outside the web root.--->

            <cffile action="upload"

                    filefield="FileName1"

                    destination="C:\temp\"

                    nameconflict="makeunique"

                    accept="application/octet-stream, application/pdf">

          

      <!--- The file is on the web server now. Read it as a binary and put the result in the ColdFusion variable file_blob --->

             <cffile action = "readbinary"

                     file = "C:\temp\#cffile.serverFile#"

                     variable="file_blob">

                       

      <!---  Insert the ColdFusion variable file_blob into the table, making sure to select cf_sql_blob as the sql type. --->

              <cfquery name="q" datasource="#oracle_db#" username="#spoc_db#" password="#spoc_pw#">

                     insert into spoc_attachments (

                                FILE_NUMBER, ATTACH_ID, ATTACHMENT, ATTACH_TITLE

                                )

                      VALUES (

                                #FileNumber#, 

                                1, 

                                <cfqueryparam

                                    value="#file_blob#"

                                    cfsqltype="cf_sql_blob">,

                                 Trim('#FileTitle1#')

                            )

              </cfquery>

                                                                      

                <cfcatch type="application">

                    Error uploading file 1     

                </cfcatch>

      </cftry>

           

</cfif>

 

------------------------------------------  rr.check.cfm

 

 

<cfoutput>

        <td><cfif ai.RecordCount GE 1><a href="rr.attachments.cfm?fn=<cfoutput>#fn#</cfoutput>&ai=1" target="_blank">#ai1.attach_title#</a></cfif>  <cfif ai.RecordCount GE 2><a href="rr.attachments.cfm?fn=<cfoutput>#fn#</cfoutput>&ai=2" target="_blank">#ai2.attach_title#</a></cfif>  <cfif ai.RecordCount GE 3><a href="rr.attachments.cfm?fn=<cfoutput>#fn#</cfoutput>&ai=3" target="_blank">#ai3.attach_title#</a></cfif>  <cfif ai.RecordCount GE 4><a href="rr.attachments.cfm?fn=<cfoutput>#fn#</cfoutput>&ai=4" target="_blank">#ai4.attach_title#</a></cfif></td>

        </cfoutput>

 

 

------------------------------------------  rr.attachments.cfm

 

<cfif not isDefined("ag")>

    <cfquery name="q1" datasource="#oracle_db#" username="#spoc_db#" password="#spoc_pw#">

        SELECT attachment

        FROM spoc_attachments

       where file_number = #fn# and attach_id = 1

    </cfquery>

    <cfquery name="q2"datasource="#oracle_db#" username="#spoc_db#" password="#spoc_pw#">

        SELECT attachment

        FROM spoc_attachments

        where file_number = #fn# and attach_id = 2

    </cfquery>

    <cfquery name="q3" datasource="#oracle_db#" username="#spoc_db#" password="#spoc_pw#">

        SELECT attachment

        FROM spoc_attachments

        where file_number = #fn# and attach_id = 3

    </cfquery>

    <cfquery name="q4" datasource="#oracle_db#" username="#spoc_db#" password="#spoc_pw#">

        SELECT attachment

        FROM spoc_attachments

        where file_number = #fn# and attach_id = 4

    </cfquery>

   

   

    <cfif ai EQ 1>

        <cfcontent

        type="application/pdf"

        variable="#q1.attachment#">

    <cfelseif ai EQ 2>

        <cfcontent

        type="application/pdf"

        variable="#q2.attachment#">

    <cfelseif ai EQ 3>

        <cfcontent

        type="application/pdf"

        variable="#q3.attachment#">

    <cfelseif ai EQ 4>

        <cfcontent

        type="application/pdf"

        variable="#q4.attachment#">

    </cfif>

<cfelse>

    <cfquery name="ag1" datasource="#oracle_db#" username="#spoc_db#" password="#spoc_pw#">

        SELECT attachment

        FROM spoc_comments

       where file_number = #fn# and agency= #ag#

    </cfquery>

   

    <cfcontent

        type="application/pdf"

        variable="#ag1.attachment#">

       

</cfif>    


Viewing all articles
Browse latest Browse all 78799

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>