The URL you are PUTting to does not appear to expect a form, but raw content, so you will not want to use the "form" generator. You can pass raw content as a bare argument like so:
$self->ua->put_p($url, $file_object->asset->slurp); You will probably also want to set a Content-Type header for the MIME type of the file contents. This would be set by a hash between the URL and content, there are some examples in https://metacpan.org/pod/Mojo::UserAgent#SYNOPSIS. -Dan On Wed, Jul 15, 2020 at 10:00 PM Gordon Dollarnanda <anexi...@gmail.com> wrote: > > hi guys, > > Just started on a project with Mojolicious. > > Task: to upload a file into mojo and then issue a PUT command to transfer > that file to a file server. > > I have been struggling to find documentation on using put_p/put in terms > of the parameters for the syntax. > > Often, looking at https://mojolicious.org/perldoc/Mojo/UserAgent#put_p, > it is too brief and not concise. > I have also tried to look for the source code in the Mojolicious > framework which does the actual put_p/put to no avail. I had looked up the > source of Mojo <https://mojolicious.org/perldoc/Mojo> :: UserAgen > <https://mojolicious.org/perldoc/Mojo/UserAgent>t and the packages it is > "use"-ing also to no avail. > > -------- > $self->ua->put_p( > > # my_target_url_object is a Mojo::URL with the > # user info and actual url of the > # file server defined. > > # $file_object is a Mojo::File::Asset representing a file I > had uploaded from my local machine > > * $my_target_url_object => form => {* > > * 'content' => $file_object->asset->{'content'}, > }* > )->then( > sub ($tx) { > return $self->parse_response_p($tx); > } > )->catch( > sub($error) { > p->reject("Connection error: $error"); > } > ); > ----------- > When I use the put call above, the content of my input file becomes > "content=+Why+Georgia%3F%0A" instead of just "Why Georgia" (which was what > I had uploaded earlier). > I must be doing something wrong. > > I have since tried many variations to the call to put_p to no avail. > Sometimes, if i do not provide the hash key, 'content', the actual cost > when i cat the file in the target webserver directory would be literally > 'HASH%3234234234'; > > Can any one please point me to proper documentation clearly describing how > to execute a put/put_p in a Mojolicious controller? > > Thank you, guys > > > Gordon > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/mojolicious/19d370c9-81e3-4a52-aac9-254eef693bb8n%40googlegroups.com > <https://groups.google.com/d/msgid/mojolicious/19d370c9-81e3-4a52-aac9-254eef693bb8n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/CABMkAVXTWi%3DLbW%3DW_4B2%2BCfbJFattYVB9Sh%3DxMsAsP3Eg60zYA%40mail.gmail.com.