2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: GS_HTTP/Peacekeeper-plugin
[Re: Joey]
#97468
11/15/06 23:58
11/15/06 23:58
|
Joined: Jun 2005
Posts: 4,875
broozar
OP
Expert
|
OP
Expert
Joined: Jun 2005
Posts: 4,875
|
|
|
|
Re: GS_HTTP/Peacekeeper-plugin
[Re: broozar]
#97469
11/16/06 00:05
11/16/06 00:05
|
Joined: Jun 2005
Posts: 4,875
broozar
OP
Expert
|
OP
Expert
Joined: Jun 2005
Posts: 4,875
|
this is the code that comes along with the dll in a *.pas file, i guess it's what you'd call the source code: Quote:
function HTTP_PostFile(id: gsfixed; URL,Filename, pVar: PA4_STRING): gsfixed; const LR : String[2] = #13#10; var Buf,Boundry,ContentTypePost,PostVar: String; FileToSend : TMemoryStream; Error: Integer; function Inputtext(Name,Value: String): string; begin result := format(lr+'%s%sContent-Disposition: form-data; name="%s"%s%s%s%s'+#13#10,[boundry,lr,name,lr,lr,lowercase( value ),lr] ); end; begin Error := 0; try PostVar := StrPas(pVar^.chars); THTTPCli(HTTPList[FIX2INT(id)]).SendStream := TMemoryStream.Create;
Boundry := '-----------------------------7cf29e12c04'; { Specified in Multipart/form-data RFC } ContentTypePost := 'multipart/form-data; boundary=' + copy(Boundry,3,length(boundry));
Buf := Boundry + LR + 'Content-Disposition: form-data; name="uploadFile1"; filename="' + ExtractFileName(ExtractFilePath(ParamStr(0)) + StrPas(filename^.chars)) + '"' + LR + 'Content-Type: application/x-compress' + LR + LR; //i don't think the IMAGE/PJPEG matters much //my opinion on this would be that once it's set as this //the file will be uploaded in BINARY
THTTPCli(HTTPList[FIX2INT(id)]).SendStream.Write(Buf[1], Length(Buf));
FileToSend := TMemoryStream.Create; // Open File with TMemorystream FileToSend.LoadFromFile(ExtractFilePath(ParamStr(0)) + StrPas(filename^.chars)); // load it up FileToSend.SaveToStream(THTTPCli(HTTPList[FIX2INT(id)]).SendStream); // Dump out file to TMemorystream FileToSend.Free; // andddd free it up if PostVar<>'' then Buf := InputText('variable',PostVar); Buf := ConCat(buf,Boundry+'--'); {This is to signify the END of our transactions } THTTPCli(HTTPList[FIX2INT(id)]).SendStream.Write(Buf[1], Length(Buf));
TMemoryStream(ResultList[FIX2INT(id)]).Clear; THTTPCli(HTTPList[FIX2INT(id)]).RcvdStream := TMemoryStream(ResultList[FIX2INT(id)]); THTTPCli(HTTPList[FIX2INT(id)]).SendStream.Seek(0,0); THTTPCli(HTTPList[FIX2INT(id)]).URL := StrPas(URL^.chars); WorkList[FIX2INT(id)] := '1'; THTTPCli(HTTPList[FIX2INT(id)]).PostAsync; except Error := 1; end; result := INT2FIX(Error); end;
|
|
|
Re: GS_HTTP/Peacekeeper-plugin
[Re: broozar]
#97470
11/16/06 03:49
11/16/06 03:49
|
Joined: Nov 2003
Posts: 108 Oklahoma, USA
FixxeR
Member
|
Member
Joined: Nov 2003
Posts: 108
Oklahoma, USA
|
This may be a stupid question to ask, but since you're executing a PHP file from the A6 Engine I thought I should. Do you have Apache/PHP running, or a background PHP interpreter, to execute the PHP code?
Edit: Okay, I see now that you're executing the PHP file from a server. I'll start testing it to see if I can get it to work.
FixxeR
Last edited by FixxeR; 11/16/06 03:56.
|
|
|
Re: GS_HTTP/Peacekeeper-plugin
[Re: FixxeR]
#97473
11/19/06 18:04
11/19/06 18:04
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
Has someone an idea how to pass (set up) a proxy with GS_HTTP/Peacekeeper-plugin?
thanx, mercuryus
|
|
|
Re: GS_HTTP/Peacekeeper-plugin
[Re: broozar]
#97475
11/27/06 21:02
11/27/06 21:02
|
Joined: Jun 2005
Posts: 4,875
broozar
OP
Expert
|
OP
Expert
Joined: Jun 2005
Posts: 4,875
|
this is the official answer: Quote:
Just use HTTP_PostFile2()? The forth variable in HTTP_PostFile() is for sending name=value pairs in addition to the file.
The path of the file is:
ExtractFilePath(ParamStr(0)) + StrPas(filename^.chars)
Which means ExtractFilePath(c:\whatever\whatever\myacknex.exe) + filename.
In the case of preview or whatever in A6 the file would need to be in the same directory as the acknex EXE which is the gstudio\bin dir. Also if you include directory slashs in that filename you have to double them up.
So: c:\program files\gstudio\bin\acknex.exe c:\program files\gstudio\bin\gshttp.dll c:\program files\gstudio\bin\images\myfile.jpg c:\program files\gstudio\bin\myfile2.jpg c:\program files\gstudio\myproject\whatever.wdl
HTTP_PostFile2(0, 'http://www.whatever.com/whatever.php','images\\myfile.jpg');
HTTP_PostFile2(0, 'http://www.whatever.com/whatever.php','myfile2.jpg');
Published it would be something like: c:\program files\myproject\acknex.exe c:\program files\myproject\gshttp.dll c:\program files\myproject\images\myfile.jpg c:\program files\myproject\myfile2.jpg c:\program files\myproject\whatever.wdl
Something like that.
Also, the GS_Python plugin provides more robust HTTP stuff.
Thanks, Cellulaer
now i do get a string back, it says "FAILURE", which is certainly fron the php script. something must be wrong there.
now, this is my code:
Code:
dll_handle = dll_open("GSHTTP.dll"); HTTP_Create(0); HTTP_PostFile2 (0, "http://whateverurl/anonymus-upload.php", serversettings); //serversettings is a file namend "workstation1.bz3", a plain text file while (HTTP_IsWorking(0)==1) { wait(1); } HTTP_Results(0,results_str); HTTP_Free(0); dll_close(dll_handle); wait(1);
////////////////////////////////////////////////this was the wdl code, now the php:
<?php if (count($_FILES) && $_FILES['name']['error']) { $filename = $_FILES['name']['name']; if (move_uploaded_file($_FILES['name']['tmp_name'], $filename)) { echo "SUCCESS"; } else { echo "FAILURE"; } } else { echo "FAILURE"; } ?>
|
|
|
|