Create "web page" on the fly in AIR

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Create "web page" on the fly in AIR

Paul Stearns
Is there any methods where I can receive a stream of data from an HTTP request into a variable in AIR, then send the data to the default browser without first writing the file to disk?

Paul R. Stearns
Advanced Consulting Enterprises, Inc.

15280 NW 79th Ct.
Suite 250
Miami Lakes, Fl 33016

Voice: (305)623-0360 x107
Fax: (305)623-4588


Reply | Threaded
Open this post in threaded view
|

Re: Create "web page" on the fly in AIR

Paulus de B.
Hi Paul,

You can create a local web server to your AIR app and redirect the user to
this local URL/port. This way you can stream anything you want to the
browser from your own local AIR web server.

Here's an example:
https://github.com/leopoldodonnell/airhttp

Cheers

Paulus



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Create "web page" on the fly in AIR

Paul Stearns
Paulus:

Seems like a good tool. I wanted to keep my question short, but I should have mentioned what my final end goal is to send an embedded mime type of a PDF file. What I need this for mainly is to display reports PDF which are created on the fly from a application which only accepts "POST" requests.

My app sends a HTTP/POST to a web service, it responds with a "file" with a mime type of PDF. I would like to redirect the data stream to something which can display the PDF without writing it to disk first.

The current Flash applications just requests/redirects the resultant data stream to a new window/tab using navigateToURL(urlRequest,"_blank").

Paul R. Stearns
Advanced Consulting Enterprises, Inc.

15280 NW 79th Ct.
Suite 250
Miami Lakes, Fl 33016

Voice: (305)623-0360 x107
Fax: (305)623-4588

----------------------------------------
From: "Paulus de B." <[hidden email]>
Sent: 6/23/20 3:58 AM
To: [hidden email]
Subject: Re: Create "web page" on the fly in AIR
Hi Paul,

You can create a local web server to your AIR app and redirect the user to
this local URL/port. This way you can stream anything you want to the
browser from your own local AIR web server.

Here's an example:
https://github.com/leopoldodonnell/airhttp

Cheers

Paulus

--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/


Reply | Threaded
Open this post in threaded view
|

Re: Create "web page" on the fly in AIR

Paulus de B.
Hi Paul,

What if you create a local web server in AIR that when requested from the
browser (HTTP GET) performs a HTTP POST from your application to your server
and streams the response back to the browser? Doesn't that solve the
problem?

Cheers

Paulus



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Create "web page" on the fly in AIR

Paul Stearns
Paulus:

I do not quite understand the approach outlined. I will restate what I currently do in Flash;

My Flash application, in many places, will create an HTTP/POST request which is sent to a web service. This web service takes the request and all of the POSTed arguments, runs a report generator and spits back a PDF "file" using the proper mime type. I do this from Flash using navigateToURL(urlRequest,"_blank") which causes the browser to pop up a new window/tab that receives the mime type PDF and launches the pdf viewer.

I need to convert this into AIR, but navigateToURL will convert POST requests to GET which the report generator ignores.

Paul R. Stearns
Advanced Consulting Enterprises, Inc.

15280 NW 79th Ct.
Suite 250
Miami Lakes, Fl 33016

Voice: (305)623-0360 x107
Fax: (305)623-4588

----------------------------------------
From: "Paulus de B." <[hidden email]>
Sent: 6/23/20 8:26 AM
To: [hidden email]
Subject: Re: Create "web page" on the fly in AIR
Hi Paul,

What if you create a local web server in AIR that when requested from the
browser (HTTP GET) performs a HTTP POST from your application to your server
and streams the response back to the browser? Doesn't that solve the
problem?

Cheers

Paulus

--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/


Reply | Threaded
Open this post in threaded view
|

RE: Create "web page" on the fly in AIR

Idylog - Nicolas Granon
Hi Paul,

For your information, we did run into the same exact problem when migrating our apps from FlashPlayer to AIR runtime (we generate reports in HTML or PDF format on the server and display them in a separate browser tab).

We have tried the 'inner' AIR browser solution but :
- it is quite complicated to setup, due to the security model (trusted domain vs untrusted domain) especially if your have dynamic data flowing to and from the remote http server (report parameters, error codes etc.). But it can be managed.
- but what we did discover (after having done the hard work, of course) is that CSS support of the embedded AIR browser is very poor (which was a real problem since we have a number of html reports and printouts) and not very consistent between MacOS and Windows. In the end, it was not a viable solution.
(also, we found performances to be so-so compared with recent browsers).

In the end, we have chosen the 'http/get' way (much simpler), with a simple (but effective) encrypting of the url parameters.
It is a bit ugly (but users don't seem to mind) and your are of course limited by the maximum length of url parameters (which is *not* so tiny, in fact, in modern browsers).
The server sends a session key in the early stages of the application and uses it for decoding url parameters.

Maybe there are other and smarter ways (sockets ?)...

Hope this helps!

Regards

Nicolas Granon

IDYLOG
Digital Engineering

13 Bd Princesse Charlotte
Monaco

[hidden email]
06.22.52.69.77

-----Message d'origine-----
De : Paul Stearns <[hidden email]>
Envoyé : mardi 23 juin 2020 15:12
À : [hidden email]; [hidden email]
Objet : Re: Create "web page" on the fly in AIR

Paulus:

I do not quite understand the approach outlined. I will restate what I currently do in Flash;

My Flash application, in many places, will create an HTTP/POST request which is sent to a web service. This web service takes the request and all of the POSTed arguments, runs a report generator and spits back a PDF "file" using the proper mime type. I do this from Flash using navigateToURL(urlRequest,"_blank") which causes the browser to pop up a new window/tab that receives the mime type PDF and launches the pdf viewer.

I need to convert this into AIR, but navigateToURL will convert POST requests to GET which the report generator ignores.

Paul R. Stearns
Advanced Consulting Enterprises, Inc.

15280 NW 79th Ct.
Suite 250
Miami Lakes, Fl 33016

Voice: (305)623-0360 x107
Fax: (305)623-4588

----------------------------------------
From: "Paulus de B." <[hidden email]>
Sent: 6/23/20 8:26 AM
To: [hidden email]
Subject: Re: Create "web page" on the fly in AIR Hi Paul,

What if you create a local web server in AIR that when requested from the browser (HTTP GET) performs a HTTP POST from your application to your server and streams the response back to the browser? Doesn't that solve the problem?

Cheers

Paulus

--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/



Reply | Threaded
Open this post in threaded view
|

RE: Create "web page" on the fly in AIR

Paul Stearns
Thanks.

I decided on a different approach, unless something better comes along, I create a public application variable tempReports followed by 2 random digits. I use that to build a folder in the applicationStorageDirectory area. All reports get written there and I launch the default application with file.openWithDefaultApplication().

When the application is closed I delete the folder & contents.

When the application is launched I delete all tempReports(nn) folders. To clean up in case something got left behind.

I also added logic to add versions to the file names in the tempReports folder if the file already exists [myReport.pdf, myReport(1).pdf, myReport(2).pdf].

If you are wondering about the reason for the numbers at the end of the tempReports folder, it is my intention to allow multiple copies of the program to run simultaneously, which is how some users currently use the Flash applications.

Paul R. Stearns
Advanced Consulting Enterprises, Inc.

15280 NW 79th Ct.
Suite 250
Miami Lakes, Fl 33016

Voice: (305)623-0360 x107
Fax: (305)623-4588

----------------------------------------
From: "IDYLOG - Nicolas Granon" <[hidden email]>
Sent: 6/23/20 10:27 AM
To: <[hidden email]>, <[hidden email]>
Subject: RE: Create "web page" on the fly in AIR
Hi Paul,

For your information, we did run into the same exact problem when migrating our apps from FlashPlayer to AIR runtime (we generate reports in HTML or PDF format on the server and display them in a separate browser tab).

We have tried the 'inner' AIR browser solution but :
- it is quite complicated to setup, due to the security model (trusted domain vs untrusted domain) especially if your have dynamic data flowing to and from the remote http server (report parameters, error codes etc.). But it can be managed.
- but what we did discover (after having done the hard work, of course) is that CSS support of the embedded AIR browser is very poor (which was a real problem since we have a number of html reports and printouts) and not very consistent between MacOS and Windows. In the end, it was not a viable solution.
(also, we found performances to be so-so compared with recent browsers).

In the end, we have chosen the 'http/get' way (much simpler), with a simple (but effective) encrypting of the url parameters.
It is a bit ugly (but users don't seem to mind) and your are of course limited by the maximum length of url parameters (which is *not* so tiny, in fact, in modern browsers).
The server sends a session key in the early stages of the application and uses it for decoding url parameters.

Maybe there are other and smarter ways (sockets ?)...

Hope this helps!

Regards

Nicolas Granon

IDYLOG
Digital Engineering

13 Bd Princesse Charlotte
Monaco

[hidden email]
06.22.52.69.77

-----Message d'origine-----
De : Paul Stearns <[hidden email]>
Envoyé : mardi 23 juin 2020 15:12
À : [hidden email]; [hidden email]
Objet : Re: Create "web page" on the fly in AIR

Paulus:

I do not quite understand the approach outlined. I will restate what I currently do in Flash;

My Flash application, in many places, will create an HTTP/POST request which is sent to a web service. This web service takes the request and all of the POSTed arguments, runs a report generator and spits back a PDF "file" using the proper mime type. I do this from Flash using navigateToURL(urlRequest,"_blank") which causes the browser to pop up a new window/tab that receives the mime type PDF and launches the pdf viewer.

I need to convert this into AIR, but navigateToURL will convert POST requests to GET which the report generator ignores.

Paul R. Stearns
Advanced Consulting Enterprises, Inc.

15280 NW 79th Ct.
Suite 250
Miami Lakes, Fl 33016

Voice: (305)623-0360 x107
Fax: (305)623-4588

----------------------------------------
From: "Paulus de B." <[hidden email]>
Sent: 6/23/20 8:26 AM
To: [hidden email]
Subject: Re: Create "web page" on the fly in AIR Hi Paul,

What if you create a local web server in AIR that when requested from the browser (HTTP GET) performs a HTTP POST from your application to your server and streams the response back to the browser? Doesn't that solve the problem?

Cheers

Paulus

--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/