Post mime data with httprequest

526 views
Skip to first unread message

Louis

unread,
Apr 12, 2010, 6:12:36 AM4/12/10
to Caché, Ensemble, DeepSee
Hallo all,

I try to upload a form with mime data like this

S httprequest=##class(%Net.HttpRequest).%New()
S httprequest.Server="www.server.com"
S httprequest.ContentEncoding="base64"
S httprequest.ContentType="multipart/form-data"
D httprequest.InsertFormData("file","value")
D httprequest.Post("/ad/upload.csp")
D httprequest.HttpResponse.OutputToDevice()

but the code on the csp-page like this:

W "M:"_$O(%request.MimeData("")),!
W "F:"_$O(%request.Data("")),!

Say i get request something in request.data not in request.mimedata

I need this to upload a file from a server to a webserver using http

Alexander Riemer

unread,
Apr 15, 2010, 3:35:10 PM4/15/10
to Caché, Ensemble, DeepSee
Louis,

what do you want to do? Upload a file?

Regards
Alex

Louis

unread,
Apr 21, 2010, 3:02:44 AM4/21/10
to Caché, Ensemble, DeepSee
Hi alex yes.
but not with ftp.
--
InterSystems: Advanced software technologies for breakthrough applications

Caché 2010.1.1 released on April 8, 2010

Subscription settings: http://groups.google.com/group/intersystems-public-cache/subscribe?hl=en

Alexander Riemer

unread,
Apr 24, 2010, 4:19:12 PM4/24/10
to Caché, Ensemble, DeepSee
Hello Louis,

I had the same problem two years ago. At the end I found out
%Net.HttpRequest in Caché 2008.2 is not able to upload a file as part
of a multipart/form-data.

I end up writing a SOAP webservice as I could influence the client and
the server. It seems you can do too. So that's my advice. Do it with a
webservice.

Louis

unread,
Apr 28, 2010, 10:24:02 AM4/28/10
to Caché, Ensemble, DeepSee
Hi Alex,

Thanks for your feedback. Now i know it is not in this version yet :)
I think i take your advice and make it into a webservice.

regards,

louis

GARY KINSEY

unread,
May 12, 2010, 1:25:18 PM5/12/10
to intersystems...@googlegroups.com
Does anyone have example code for using the %Net.HttpClass with SSL?

My code for a bank page:

s httprequest=##class(%Net.HttpRequest).%New()
httprequest.Https="true"
httprequest.SSLConfiguration="bankcon"
httprequest.Port=443
s httprequest.Server="www.bankserver.com"
 d httprequest.Get("/acctgrp/acct")
 d httprequest.HttpResponse.OutputToDevice()
 q

The reply I get:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
</HEAD><BODY>:
<BLOCKQUOTE>HINT: <a href="https://www.bankserver.com/"><b>https://www.bankserver.com/</b></a></blockquote></p>
<H1>BAD REQUEST</H1>:
<HTML><HEAD>:
<P>YOUR BROWSER SENT A REQUEST THAT THIS SERVER COULD NOT UNDERSTAND.<BR />:
<TITLE>400 BAD REQUEST</TITLE>:
INSTEAD USE THE HTTPS SCHEME TO ACCESS THIS URL, PLEASE.<BR />:
REASON: You're speaking plain HTTP to an SSL-enabled server port.<br />

Thanks

Alex Schaefer

unread,
May 14, 2010, 9:09:07 AM5/14/10
to intersystems...@googlegroups.com

The Https property is a %Boolean so if you set it to 1 instead of “true” that might make a difference.  Does your bankcon SSL configuration work from the System Management Portal if you test it there?

 


Laser Lips

unread,
May 18, 2010, 5:33:46 AM5/18/10
to Caché, Ensemble, DeepSee
Have you seen the upload example in your CACHE samples folder?

C:\CacheSys\CSP\samples\upload.csp

Graham

Waldner Colombo Guinzani

unread,
May 18, 2010, 11:17:31 PM5/18/10
to intersystems...@googlegroups.com
wonderful

2010/5/18 Laser Lips <louds...@gmail.com>



--

abraço,
______________________________
Waldner
W One Sistemas
(48) 9134-8040
msn  : wal...@pop.com.br
skype: waldner.guinzani
Gmail: waldner....@gmail.com
______________________________

Laser Lips

unread,
May 19, 2010, 9:07:09 AM5/19/10
to Caché, Ensemble, DeepSee
It's not a full listing as it only get's the file up to the server and
gives you info...but if you use this snippet of code below you can
acutally get the file on to the server...


Set stream=##class(%FileBinaryStream).%New()
Set stream.Filename="c:\myfolder\myfile.jpg"
do stream.CopyFrom(%request.MimeData("FileStream",1))
do stream.Flush()
do stream.SaveStream()
kill stream

On May 19, 4:17 am, Waldner Colombo Guinzani
<waldner.guinz...@gmail.com> wrote:
> wonderful
>
> 2010/5/18 Laser Lips <loudsphi...@gmail.com>
>
> > Have you seen the upload example in your CACHE samples folder?
>
> > C:\CacheSys\CSP\samples\upload.csp
>
> > Graham
>
> > --
> > InterSystems: Advanced software technologies for breakthrough applications
>
> > Caché 2010.1.1 released on April 8, 2010
>
> --
>
> abraço,
> ______________________________
> Waldner
> W One Sistemas
> (48) 9134-8040
> msn  : wald...@pop.com.br
> skype: waldner.guinzani
> Gmail: waldner.guinz...@gmail.com
> ______________________________
>
> --
> InterSystems: Advanced software technologies for breakthrough applications
>
> Caché 2010.1.1 released on April 8, 2010

Reply all
Reply to author
Forward
0 new messages