It is currently Mon Apr 06, 2020 2:57 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: HttpRequest receiving Binary File
PostPosted: Thu Sep 19, 2019 7:36 am 
Offline
New User
New User

Joined: Thu Sep 19, 2019 7:26 am
Posts: 5
Hello and thank you for a lot of Advices that I could find in this forum, whenever I needed Help.

Now I couldnt find a solution, I ve got a problem with HttpRequest()

Code:
Global NewMap Header$()
Header$("ContentType") = "application/octet-stream"

InitNetwork()
httpRequest = HTTPRequest(#PB_HTTP_Get, "apiserver/api/v1/Document/17232", "", 0, Header$())
...


A Request on this server receives a Binary file, it can be a PDF or an Image. When I open this URL in Browser it works fine, and the download Dialog opens. How can I save the response of this request to disk in PB ?

Thank you for your help ;-)

Lunne


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest receiving Binary File
PostPosted: Thu Sep 19, 2019 7:42 am 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1067
Location: Amphibios 9
Hello Lunne,

maybe ReceiveHTTPFile is what you're looking for.

Greetings ... Peter

_________________
Can't decide if i need a hug, an XXL coffee, 6 shots of vodka or 2 weeks of sleep.


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest receiving Binary File
PostPosted: Thu Sep 19, 2019 7:53 am 
Offline
New User
New User

Joined: Thu Sep 19, 2019 7:26 am
Posts: 5
Thank you.

It works with receiveFile, the problem is, that I need to specify a file name, the file name is included in the Stream.

Do you know how to read filename attributes in the Header of the answer of the HttpRequest ?


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest receiving Binary File
PostPosted: Fri Sep 20, 2019 7:42 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4590
Location: Germany
Unfortunately (until Fred implements my feature requests) it is only possible with libcurl.pbi

viewtopic.php?p=537377#p537377


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest receiving Binary File
PostPosted: Sat Sep 21, 2019 2:34 pm 
Offline
New User
New User

Joined: Thu Sep 19, 2019 7:26 am
Posts: 5
It works with curl. It would be great to have it included in PB natively. Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest receiving Binary File
PostPosted: Sat Sep 21, 2019 6:52 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4590
Location: Germany
:mrgreen: :mrgreen: :mrgreen:

curl is included in PB. You don't need an extra library, but Fred's implementation is a bit restricted.
I already placed some feature requests :wink:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: citystate and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye