Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Upload to Amazon S3
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01530635
Message ID:
01531088
Views:
93
Brandon,

That shouldn't be necessary. If you do:
loHttp.AddPostKey("file","c:\temp\somefile.pdf",.T.)
it should do the FileToStr() conversion for you. You don't want to change that code - it definitely works. Otherwise that'll get blown away next time. The previous change I showed is integrated into the next rev of the tools.

Regards,

+++ Rick ---

>Rick,
>
>Thanks, this got me even closer to a working solution. I had to make one other adjustment in the wwhttp.prg source
>
>I had to drop the filename="" from the addpostkey function
>
>
>THIS.cPostBuffer = THIS.cPostBuffer + ;
>            "--" + MULTIPART_BOUNDARY + CR + ;
>            [Content-Disposition: form-data; name="]+tcKey+[" filename="] + tcValue + ["]+CR+CR+;
>            FILETOSTR(tcValue) + CR
>
>
>to
>
>
>THIS.cPostBuffer = THIS.cPostBuffer + ;
>            "--" + MULTIPART_BOUNDARY + CR + ;
>            [Content-Disposition: form-data; name="]+tcKey+["]+CR+CR+;
>            FILETOSTR(tcValue) + CR
>
>
>>Do you have the source version? there's a bug that's snuck in a while back and it looks like you're hitting that.
>>
>>
>>IF tnPostSize > 0
>>   DO CASE
>>      CASE !EMPTY(this.cContentType)
>>		 	tcHeaders = "Content-Type: " + this.cContentType + CRLF + tcHeaders      
>>      CASE THIS.nhttppostmode = 1
>>         tcHeaders = "Content-Type: application/x-www-form-urlencoded"  + CRLF +;
>>            IIF(!EMPTY(tcHeaders),CRLF+tcHeaders,"")
>>      CASE THIS.nhttppostmode = 2
>>         tcHeaders = "Content-Type: multipart/form-data; boundary=" + MULTIPART_BOUNDARY + CRLF + CRLF +;
>>            IIF(EMPTY(tcHeaders),"",tcHeaders)
>>
>>         *** NOTE: extra dashes required to simulate browser operation!
>>         lcPostBuffer = lcPostBuffer + "--" + MULTIPART_BOUNDARY + "--"  + CRLF
>>         tnPostSize=LEN(lcPostBuffer)
>>      OTHERWISE      && CASE THIS.nhttppostmode = 4  && XML or Raw
>>         tcHeaders = "Content-Type: text/xml" + CRLF + tcHeaders		 
>>   ENDCASE
>>ELSE
>>   tcHeaders =  IIF(!EMPTY(tcHeaders),tcHeaders,"")
>>ENDIF
>>
>>
>>(in the wwHttp::httpgetex method - just replace that block there's only a very small change)
>>
>>Basically the trailing -- were missing previously.
>>
>>This has come up in the last weeks a couple of times but what's odd is that I've had this set for years and I've been using to upload to a host of different servers.
>>
>>It's fixed, but not in any active release at this point. If you have source code you can make that change yourself. Otherwise I'll try to patch the existing versions.
>>
>>As always you get a faster response when you post on our message board as I'm not checking here every day.
>>
>>Aloha,
>>
>>
>>+++ Rick ---
>>
>>>>You should use wwHttp to do this - wwIPStuff has been deprecated. Same syntax but separate object. Use the HttpGet() method which make your code simpler as well.
>>>>
>>>>
>>>>Main issue is that you need to use multi-part form posting for uploading a file. loHttp.nHttpPostMode = 2 should address that. In addition I'm not sure you're sending the 'file' correctly.
>>>>
>>>>Here's an example from the help file:
>>>>http://www.west-wind.com/webconnection/wwClient_docs?page=_0rs0twgr6.htm
>>>
>>>Thanks Rick, I'm getting much closer. Now the error message I get from S3 is The body of your POST request is not well-formed
>>>
>>>I'm using nhttppostmode=2
>>>
>>>Any ideas?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform