5 Replies Latest reply on Feb 22, 2011 8:10 AM by BruceNewsY

    Write a server-side file

    BruceNewsY Level 1

      Our FlashBuilder web app has a file in a ByteArray with a string pointer.

      How can we write the ByteArray (or the string) to a server file (prefer a PDF or SWF file extension)?

      The server file can be temporary.

       

      many thanks

        • 1. Re: Write a server-side file
          miguel8312

          you can use a webservice, or a remote service thus are just some of the possibilites.

          Miguel

          • 2. Re: Write a server-side file
            saisri2k2 Level 4

            You might use blazeds for that. or you can use filereference. If it is an image, you can convert it into base64 and send it to the server and decode it.

            1 person found this helpful
            • 3. Re: Write a server-side file
              BruceNewsY Level 1

              A closer look at architecture follows:

               

              user web browser <-- FB4 web app <-- SOAP/WSDL <-- DB file server

               

              From their web browser, the user launches our hosted web app.  Then the user selects a file to view. The web app fetches the Base64 encoded file from the DB (which cannot expose the file URL), decodes it, strips the SOAP/WSDL wrapper, checks the file type and points to the ByteArray with a String. If the file is *.png *.jpg or *.gif, then the web app displays the image.

               

              If the file is *.PDF (90% are PDFs) then the web app must:

              1) write the file to its own disk as a PDF or SWF and send that file URL to a web hosted iFrame to display (for example, FlashPaper).

              or

              2) convert the file JPG, PNG and display the resulting (possibly multi-page) image

               

              As I understand, fileReference prompts the user to save to their PC.  But, we do not write sensitive files to the user's PC.

               

              Can a hosted web app write to its own disk?

               

              Otherwise I need to write from the web app to a web server (such as blazeds) in a session IIS cluster, then find and use the file URL.

               

              Is it that complicated to show a PDF from a web app?

              thanks,

              Bruce

              • 4. Re: Write a server-side file
                saisri2k2 Level 4

                So, you want to open an image/file and save the modifications back into the server? If you open a file from the server, and want to save it back, then it is kinda not possible for pdf, you might end up opening pdf in a separate window where flex is not used(Only java script). For images, you can show it on the UI and any modification you do, is actually done on the image in flex, so, you can save the bytearray back intto the server.

                • 5. Re: Write a server-side file
                  BruceNewsY Level 1

                  Thanks, you are close to the issue.  Adobe web programs cannot display a PDF (except possibly for FlashPaper).  You can show a PDF in an iFrame, but you need the file URL.

                   

                  In a file-server architecture, backend DB and front-end session manager (such as Apache, IIS clusters), the Flash web app gets the file via SOAP/WSDL from the DB and cannot receive the URL due to medical security.  Therefore, the web app needs to save the ByteArray (containing a PDF string of bytes) to a local file.  The web app can then send the URL to a hosted iFrame.

                   

                  Problem becomes, how can a web app write a local file (on the Apache or IIS cserver)?

                   

                  Otherwise, we need to convert each PDF to a JPG or PNG in memory.

                   

                  We appreciate your help.  If we solve this, then we will make the process publically available.

                  Bruce