6 Replies Latest reply on Aug 8, 2012 2:15 PM by Alistair Laing

    Get file from HTTP POST (upload image)

      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:
      Content-Disposition: form-data; name="name" 
      Content-Disposition: form-data; name="chunks" 
      Content-Disposition: form-data; name="chunk" 0
      Content-Disposition: form-data; name="file"; filename="centerd.jpg" 
      Content-Type: image/jpeg
      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)
          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

            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

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


              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 ...?



                  Deutschsprachige APEX-Community: Tipps, Tricks, Best Practice

                  SQL und PL/SQL: Tipps, Tricks & Best Practice

                  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.