Re: Urgent Help needed with Post method file upload

"Eric Langheinrich" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <002701c5a032$badc83f0$0800a8c0@UNSPAM1>
Okay, so in the useragent, I pass the filename as an array reference 
[$task_add_datakey] what actually gets the contents of the file and posts 
them?

Is there another way to do it? Am I better off opening a raw socket and 
writing the headers and the data myself? My concern is that to get the raw 
binary to write properly in the first place, I had to run binmode FILEHANDLE 
":raw" on the file handle that I was writing to. From what I've read, I 
would need to do that on the read of the file contents as well in order to 
properly get the data. Is the library setup to handle raw binary data?


----- Original Message ----- 
From: "Gisle Aas" <[email protected]>
To: "Eric Langheinrich" <[email protected]>
Cc: <[email protected]>
Sent: Saturday, August 13, 2005 12:05 PM
Subject: Re: Urgent Help needed with Post method file upload


> "Eric Langheinrich" <[email protected]> writes:
>
>> I'm attempting to post a file in a multipart/form-data post using
>> LWP::UserAgent and the following command string:
>>
>>  my $response = $ua->request(POST $baseurl, Content_Type => 'form-data', 
>> Content => [ request_params => $task_add_postkey, datafile => 
>> [$task_add_datakey] ]);
>>
>>
>> Where $task_add_postkey is a set of key value pairs of form data,
>> and $task_add_datakey is the full path file name of a file
>> containing binary data. The post seems to work fine with the
>> exception of the 48 byte file I am sending, is received as 61 bytes
>> on the server. I'm assuming it has something to do with how the file
>> is being parsed.
>
> Are you able to inspect the file received on the server side to figure
> out what is actually different?
>
>> Is there a better way to put together a multipart post? Am I missing
>> something obvious? Is there a way to control the file parser so that
>> the data is handled as raw binary data?
>
> The file should already be included as binary.  There is no file
> parser involved.
>
>> Any ideas????
>
> Try to print the request that POST() returns above to see if you can
> spot what is wrong.
>
>  $req = POST($baseurl, ....);
>  print $req->as_string;
>
>  $res = $ua->request($req);
>  ...
>
> Regards,
> Gisle
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.