6 Replies Latest reply: Aug 8, 2012 9:15 AM by Alistair Laing RSS

    Get file from HTTP POST (upload image)

    cardel
      Hello,
      I would like to integrate http://www.plupload.com flash component to my APEX 4.1 website. I need it because I want to resize image and transform image before upload on client side, upload multiple files etc..
      But I don't know how to read image binary data from POST method.
      When I hit "Start upload" button on plupload component it makes some transformations and creates POST method like this:
      ------pluploadboundary1334433145869 
      Content-Disposition: form-data; name="name" 
      p16qp6jm3nhan1ca46me1ocr3tu1.jpg 
      
      ------pluploadboundary1334433145869 
      Content-Disposition: form-data; name="chunks" 
      1 
      
      ------pluploadboundary1334433145869 
      Content-Disposition: form-data; name="chunk" 0
      
      ------pluploadboundary1334433145869 
      Content-Disposition: form-data; name="file"; filename="centerd.jpg" 
      Content-Type: image/jpeg
      
       ÿØÿà�JFIF������ÿÛ�„�
      ....
      ....
      
      image content
         
      now I would like to read content of this HTTP POST and read sended image and store it to DB.

      Question is... how can I read file sended with HTTP POST in APEX pl/sql process or pl/sql procedure?

      Thank you...

      Edited by: cardel on Apr 14, 2012 11:17 PM
        • 1. Re: Get file from HTTP POST (upload image)
          cardel
          No ideas? Nobody?

          I think that there must be solution how to get binary data from POST method and store it to some table with BLOB column. Standard APEX browse item do it some way, but I woul like to transform, resize image on client side before uploading to server.
          • 2. Re: Get file from HTTP POST (upload image)
            Carsten Czarski-Oracle
            Hi,

            here are my two cents ...

            this will be a bit difficult. When you use the standard APEX File upload it is not PL/SQL handling the POST request. The request is handled by the webserver - depending on the variant you are using it is either mod_plsql, the C code of the Embedded Gateway or the APEX Listener. The webserver is also doint the insert into APEX' file repository. So I see two options:

            It might be possible to configure your plugin (don't know about it) the behave the same as a standard browser upload. Then for APEX there would be no difference - mod_plsql should handle the files accordingly.

            If you want to handle the POST request yourself, as said, you can't do this in PL/SQL. It would be possible to write a Java servlet doing this and deploy that servlet on the same container as the APEX Listener (when using Apache with mod_plsql you would need an additional Java server for that) ....

            Hope this helps ...

            Best regards

            -Carsten
            • 3. Re: Get file from HTTP POST (upload image)
              cardel
              I am using embeded PL/SQL gateway.
              I have read something about DAD (Database Access Descriptors)

              http://docs.oracle.com/cd/B14099_19/web.1012/b14010/concept.htm#i1005866

              It seems that APEX is using it internally for "browse file component" because recomended table structure for that component is same as described in this documentation.

              This way I should be able create my own procedure that will be mapped as HTTP servlet and can automatically save POSTed data to database table.

              But this is only my idea, I have no experiences with DADs.
              • 4. Re: Get file from HTTP POST (upload image)
                Alistair Laing
                Did you ever get this to work? I'm looking at creating a plugin.
                • 5. Re: Get file from HTTP POST (upload image)
                  Carsten Czarski-Oracle
                  Hi Cardel,

                  whatever web listener use are using (J2EE Listener, Apache w mod_plsql or Embedded Gateway). In neither of these you will have direct access to the HTTP post request.

                  The DAD definition contains a "document tablename" ....

                  PlsqlDocumentTablename wwv_flow_file_objects$

                  The webserver directly performs the SQL insert operation into that table and you can retrieve the file using SQL afterwards. But you cannot jump into that process before the webserver has inserted the file into the table. When your PL/SQL logic starts (your PL/SQL procedure, APEX or a plugin), the file has already been inserted into that table.

                  Does that help ...?

                  regards

                  _Carsten

                  Deutschsprachige APEX-Community: Tipps, Tricks, Best Practice
                  http://tinyurl.com/apexcommunity

                  SQL und PL/SQL: Tipps, Tricks & Best Practice
                  http://sql-plsql-de.blogspot.com

                  Twitter: @cczarski @oraclebudb
                  • 6. Re: Get file from HTTP POST (upload image)
                    Alistair Laing
                    I'm trying to implement this but I'm getting wwv_flow.show - 404 File not found.