CGI to send back a file to save

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

CGI to send back a file to save

Sivakatirswami
Short version: I need to know the proper HTTP header to set to force  
a browser to save the incoming data to a file. (at least I *think*  
that's what I need to know.)

Long Scenario:

Goal: create a CGI that responds to a GET request that will  
automatically generate a

fooSoundFile.ram  "file in a variable"

  based on the query string e.g.

$QUERY_STRING = audioFile=hawaii_papayas.mp3

then the .ram filename should be "hawaii_papayas.ram"

and contain the string:

"http://www.himalayanacademy.com/audio/tropical_fruit_music/ 
hawaii_papayas.mp3"

[you should hear those papayas sing!]

Now, generating all that is a easy enough.

But the usual scenario is that you have all these .ram files prebuilt  
(which is what I am trying to avoid. Old .ram files lying around the  
web site are a *big* nuisance to maintain....) and the user clicks on  
a link

<a href="/audio/tropical_fruit_music/hawaii_papayas.ram">Real Player</a>

and the .ram file is downloaded-saved to the client side disk... Real  
Player is mapped to .ram in the internet helper apps, boots and reads  
this file and streams the audio.

I want the CGI to take over that process and serve the .ram file  
dynamically.

OK, so all I know how to do is:

put "http://www.himalayanacademy.com/audio/tropical_fruit_music/ 
hawaii_papayas.mp3" into tRamFile
http://www.himalayanacademy.com/audio/tropical_fruit_music/ 
hawaii_papayas.mp3

   put "Content-Type: text/plain" & cr
   put "Content-Length:" && the length of tRamFile & cr & cr
   put tRamFile

of course this is not going to work... that string will appear as a  
literal in the user's browser.  is it as simple as something like:

# just guessing.. I haven't a clue...

   put "Content-Type: binary/file" & cr
   put "Content-Length:" && the length of tRamFile & cr & cr
   put tRamFile

# where the browser can't read it, so it saves it

??

i.e. we can of course do a redirect, like this:
put
"http://www.himalayanacademy.com/audio/tropical_fruit_music/ 
hawaii_papayas.mp3" into tRamFile
put tRamFile into url ("file:" & "audio/tropical_fruit_music/
hawaii_papayas.ram")

   put "Status: 301 Moved Permanently" & cr
   put "Location: "  & http://www.himalayanacademy.com/audio/ 
tropical_fruit_music/hawaii_papayas.ram" & cr & cr

But, then I end up once again, with all these .ram files on disk...  
so I was hoping to find a way to pipe it straight out of the CGI...  
i.e. to take what is coming back from port 80 and save it instead of  
trying to render it...maybe this is the wrong place to ask this... I  
will take it to Experts-Exchange if no one here knows.

TIA

Sivakatirswami





_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: CGI to send back a file to save

jbv-2
Hi,

I'm a bit late on this thread, but I have some code that
might help.
What I actually do is generate on-the-fly pdf files with
Rev cgi, and users get the usual WinXP dialog asking
what they want to do with the file, save it or open it :

put "Content-Type: application/pdf" & cr & "Content-Length : " & number of chars of myPDF &
cr & "Content-Disposition: attachment; filename=" &q& myRequestName &q & cr & cr

q contains the quote char.

the above line works well under WinXP and MacOSX.
I guess a few mods (in Content-Type mostly) may solve
your problem...

Best,
JB


> Short version: I need to know the proper HTTP header to set to force
> a browser to save the incoming data to a file. (at least I *think*
> that's what I need to know.)
>
> Long Scenario:
>
> Goal: create a CGI that responds to a GET request that will
> automatically generate a
>
> fooSoundFile.ram  "file in a variable"
>
>   based on the query string e.g.
>
> $QUERY_STRING = audioFile=hawaii_papayas.mp3
>
> then the .ram filename should be "hawaii_papayas.ram"
>
> and contain the string:
>
> "http://www.himalayanacademy.com/audio/tropical_fruit_music/
> hawaii_papayas.mp3"
>
> [you should hear those papayas sing!]
>
> Now, generating all that is a easy enough.
>
> But the usual scenario is that you have all these .ram files prebuilt
> (which is what I am trying to avoid. Old .ram files lying around the
> web site are a *big* nuisance to maintain....) and the user clicks on
> a link
>
> <a href="/audio/tropical_fruit_music/hawaii_papayas.ram">Real Player</a>
>
> and the .ram file is downloaded-saved to the client side disk... Real
> Player is mapped to .ram in the internet helper apps, boots and reads
> this file and streams the audio.
>
> I want the CGI to take over that process and serve the .ram file
> dynamically.
>
> OK, so all I know how to do is:
>
> put "http://www.himalayanacademy.com/audio/tropical_fruit_music/
> hawaii_papayas.mp3" into tRamFile
> http://www.himalayanacademy.com/audio/tropical_fruit_music/
> hawaii_papayas.mp3
>
>    put "Content-Type: text/plain" & cr
>    put "Content-Length:" && the length of tRamFile & cr & cr
>    put tRamFile
>
> of course this is not going to work... that string will appear as a
> literal in the user's browser.  is it as simple as something like:
>
> # just guessing.. I haven't a clue...
>
>    put "Content-Type: binary/file" & cr
>    put "Content-Length:" && the length of tRamFile & cr & cr
>    put tRamFile
>
> # where the browser can't read it, so it saves it
>
> ??
>
> i.e. we can of course do a redirect, like this:
> put
> "http://www.himalayanacademy.com/audio/tropical_fruit_music/
> hawaii_papayas.mp3" into tRamFile
> put tRamFile into url ("file:" & "audio/tropical_fruit_music/
> hawaii_papayas.ram")
>
>    put "Status: 301 Moved Permanently" & cr
>    put "Location: "  & http://www.himalayanacademy.com/audio/
> tropical_fruit_music/hawaii_papayas.ram" & cr & cr
>
> But, then I end up once again, with all these .ram files on disk...
> so I was hoping to find a way to pipe it straight out of the CGI...
> i.e. to take what is coming back from port 80 and save it instead of
> trying to render it...maybe this is the wrong place to ask this... I
> will take it to Experts-Exchange if no one here knows.
>
> TIA
>
> Sivakatirswami
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

How do I get the resolution of an image accessed by a Player?

David Burgun
Hi,

I am open ing a TIFF file via a "player" object, I can get the Width
and Height of the image with the "formattedWidth"/"Height"
properties, but how can I get the resolution or DPI?

Thanks in Advance
Dave
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the resolution of an image accessed by a Player?

Eric Chatonet
Hi Dave,

Resolution depends on the ratio between the actual size and the  
current size of the image.
If the current size is the actual size, the resolution is 72 DPI with  
most monitors.
At half size 144 DPI, etc.
With Rev objects all this does not make sense since I think Rev  
recalculates all prints at 72 DPI when they are resized.
All things change when you want to print a TIFF image from the actual  
file by using the printer prefs. Then it works as above.
But within Rev, you always get a 72 DPI resolution.
I'm not a specialist of these things, others will correct me and  
bring to you more precise information.
It's just my two cents.

Le 18 juil. 05 à 12:23, David Burgun a écrit :

> I am open ing a TIFF file via a "player" object, I can get the  
> Width and Height of the image with the "formattedWidth"/"Height"  
> properties, but how can I get the resolution or DPI?

Best Regards from Paris,

Eric Chatonet.
----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        [hidden email]/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the resolution of an image accessed by a Player?

David Burgun
Hi,

I just need to display the current resolution with in the image (e.g
the TIFF property), I am not going to change the DPI or use it to
scale an image, it's just that we have the same images but with
different resolutions and displaying the DPI of the underlying file
is the best way to tell the difference.

Thanks a lot
Dave

>Hi Dave,
>
>Resolution depends on the ratio between the actual size and the
>current size of the image.
>If the current size is the actual size, the resolution is 72 DPI
>with most monitors.
>At half size 144 DPI, etc.
>With Rev objects all this does not make sense since I think Rev
>recalculates all prints at 72 DPI when they are resized.
>All things change when you want to print a TIFF image from the
>actual file by using the printer prefs. Then it works as above.
>But within Rev, you always get a 72 DPI resolution.
>I'm not a specialist of these things, others will correct me and
>bring to you more precise information.
>It's just my two cents.
>
>Le 18 juil. 05 à 12:23, David Burgun a écrit :
>
>>I am open ing a TIFF file via a "player" object, I can get the
>>Width and Height of the image with the "formattedWidth"/"Height"
>>properties, but how can I get the resolution or DPI?
>
>Best Regards from Paris,
>
>Eric Chatonet.
>----------------------------------------------------------------
>So Smart Software
>
>For institutions, companies and associations
>Built-to-order applications: management, multimedia, internet, etc.
>Windows, Mac OS and Linux... With the French touch
>
>Free plugins and tutorials on my website
>----------------------------------------------------------------
>Web site        http://www.sosmartsoftware.com/
>Email        [hidden email]/
>Phone        33 (0)1 43 31 77 62
>Mobile        33 (0)6 20 74 50 86
>----------------------------------------------------------------
>
>_______________________________________________
>use-revolution mailing list
>[hidden email]
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the resolution of an image accessed by a Player?

Klaus major-k
Hi David,

> Hi,
>
> I just need to display the current resolution with in the image (e.g
> the TIFF property), I am not going to change the DPI or use it to
> scale an image, it's just that we have the same images but with
> different resolutions and displaying the DPI of the underlying file
> is the best way to tell the difference.

i don't think that you can check the resolution with Rev's build in  
capabilities.

Like most (non image edititing) apps, Rev is only aware of 72 DPI and  
does
not know about "resolution" per se... Rev will always display images  
at 72 DPI!

You could use Alex Tweedley's nice "EXIF Lib" (via Rev online, i  
think) or use Applescript
& "Image Events" on a mac to retrieve image resolution (and more...)

> Thanks a lot
> Dave

Regards

Klaus Major
[hidden email]
http://www.major-k.de

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: CGI to send back a file to save

Sivakatirswami
In reply to this post by jbv-2
Aloha JB:

Yes, I did get this working with help from someone on Expert's  
Exchange.  But thank you... your note confirms the method... I use  
this for this context (sending a realAudio.ram file)

[SNIP]
put tURLStem & tMainFolder &"/" & tYear &"/" & tAudioFileName into  
tAbsoluteURL

# send this out to the browser as a file

put "Content-Type: audio/x-pn-realaudio" & cr
put "Content-Disposition: attachment; filename=real-player.ram" & cr  
& cr
put tAbsoluteURL

it works great... and opens some interesting doors for dynamic file  
delivery...

but I was told I didn't need a quote characater around the file name,  
didn't use it, and it seems to work just fine..

Regards
Sivakatirswami


On Jul 17, 2005, at 10:54 PM, jbv wrote:

> Hi,
>
> I'm a bit late on this thread, but I have some code that
> might help.
> What I actually do is generate on-the-fly pdf files with
> Rev cgi, and users get the usual WinXP dialog asking
> what they want to do with the file, save it or open it :
>
> put "Content-Type: application/pdf" & cr & "Content-Length : " &  
> number of chars of myPDF &
> cr & "Content-Disposition: attachment; filename=" &q& myRequestName  
> &q & cr & cr
>
> q contains the quote char.
>
> the above line works well under WinXP and MacOSX.
> I guess a few mods (in Content-Type mostly) may solve
> your problem...
>
> Best,
> JB
>
>
>
>> Short version: I need to know the proper HTTP header to set to force
>> a browser to save the incoming data to a file. (at least I *think*
>> that's what I need to know.)
>>
>> Long Scenario:
>>
>> Goal: create a CGI that responds to a GET request that will
>> automatically generate a
>>
>> fooSoundFile.ram  "file in a variable"
>>
>>   based on the query string e.g.
>>
>> $QUERY_STRING = audioFile=hawaii_papayas.mp3
>>
>> then the .ram filename should be "hawaii_papayas.ram"
>>
>> and contain the string:
>>
>> "http://www.himalayanacademy.com/audio/tropical_fruit_music/
>> hawaii_papayas.mp3"
>>
>> [you should hear those papayas sing!]
>>
>> Now, generating all that is a easy enough.
>>
>> But the usual scenario is that you have all these .ram files prebuilt
>> (which is what I am trying to avoid. Old .ram files lying around the
>> web site are a *big* nuisance to maintain....) and the user clicks on
>> a link
>>
>> <a href="/audio/tropical_fruit_music/hawaii_papayas.ram">Real  
>> Player</a>
>>
>> and the .ram file is downloaded-saved to the client side disk... Real
>> Player is mapped to .ram in the internet helper apps, boots and reads
>> this file and streams the audio.
>>
>> I want the CGI to take over that process and serve the .ram file
>> dynamically.
>>
>> OK, so all I know how to do is:
>>
>> put "http://www.himalayanacademy.com/audio/tropical_fruit_music/
>> hawaii_papayas.mp3" into tRamFile
>> http://www.himalayanacademy.com/audio/tropical_fruit_music/
>> hawaii_papayas.mp3
>>
>>    put "Content-Type: text/plain" & cr
>>    put "Content-Length:" && the length of tRamFile & cr & cr
>>    put tRamFile
>>
>> of course this is not going to work... that string will appear as a
>> literal in the user's browser.  is it as simple as something like:
>>
>> # just guessing.. I haven't a clue...
>>
>>    put "Content-Type: binary/file" & cr
>>    put "Content-Length:" && the length of tRamFile & cr & cr
>>    put tRamFile
>>
>> # where the browser can't read it, so it saves it
>>
>> ??
>>
>> i.e. we can of course do a redirect, like this:
>> put
>> "http://www.himalayanacademy.com/audio/tropical_fruit_music/
>> hawaii_papayas.mp3" into tRamFile
>> put tRamFile into url ("file:" & "audio/tropical_fruit_music/
>> hawaii_papayas.ram")
>>
>>    put "Status: 301 Moved Permanently" & cr
>>    put "Location: "  & http://www.himalayanacademy.com/audio/
>> tropical_fruit_music/hawaii_papayas.ram" & cr & cr
>>
>> But, then I end up once again, with all these .ram files on disk...
>> so I was hoping to find a way to pipe it straight out of the CGI...
>> i.e. to take what is coming back from port 80 and save it instead of
>> trying to render it...maybe this is the wrong place to ask this... I
>> will take it to Experts-Exchange if no one here knows.
>>
>> TIA
>>
>> Sivakatirswami
>>
>> _______________________________________________
>> use-revolution mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution