Subject Re: Content-Type Application/PDF
From Martin Altmann <altmann@altem.de>
Date Tue, 15 Oct 2019 22:04:24 +0200
Newsgroups xb2net

Am 15.10.2019 um 21:59 schrieb Osvaldo Ramirez:
> On 8/31/10 18:02, Roger Donnay wrote:
>> Roger Donnay <> Wrote:
>>
>>> Has anyone been successful at returning a PDF file into a web browser
>>> from Xb2.Net?
>>>
>>> The docs are a bit unclear about how to do this.
>>>
>>> Would I do the following?
>>>
>>> oThread:httpResponse:content := <binary contents of PDF file>
>>> oThread:httpResponse:contenttype := "Application/PDF?
>>>
>>>
>>
>> I didn't expect it to be that simple.
>> I posted my message before even trying it.
>> Works perfectly!!!!
>>
>
> Hello
> Just asking, Is it the same to return a zip file ?
>
> Best Regards
> Osvaldo Ramirez
>
Osvaldo,
almost (long lines may wrap):

local r := ThreadObject():HTTPResponse
...
if file( updatepfad + "\" + xbUnEscape( pfad ) )
   cString := substr( xbUnEscape( pfad ), at( "\", pfad ) + 1, )
   r:SetHeader( "Content-Disposition","attachment; filename=" + cString )
   r:ContentType := "application/octet-stream"
   r:SetHeader( "Content-Transfer-Encoding", "binary" )
   r:SetHeader( "Accept-Ranges", "bytes" )
   r:SetHeader( "Cache-Control", "private" )
   r:Content := BTMemoRead( updatepfad + "\" + xbUnEscape( pfad ), 1, 0,
@nError )

Best regards,
Martin

--
______________________________

Deutschsprachiges Xbase-Forum:
http://www.xbaseforum.de/
______________________________

Recent messages in this thread
 
-# Re: Content-Type Application/PDF Osvaldo Ramirez 15-Oct-2019 03:59 pm
.\# Re: Content-Type Application/PDF (Current message) Martin Altmann 15-Oct-2019 04:04 pm