[wp-hackers] Sending a file to a plugin via XMLRPC?
Alex Rayan
alexrayan69 at gmail.com
Tue Sep 17 19:33:42 UTC 2013
Hi David,
I've used the following code to upload a file to a remote WP via XML RPC:
$data = array(
'name' => basename($fn),
'type' => 'video/mp4',
'bits' => new IXR_Base64($x),
'overwrite' => false,
);
if (!$client->query('wp.uploadFile','', 'username','password',$data)) {
die('An error occurred -
'.$client->getErrorCode().":".$client->getErrorMessage());
}
$response = $client->getResponse();
$video = $response['url'];
Might not be useful to you though if the files are too large.
Thought I'd share anyway.
For large files I used cURL.
Best regards,
Alex
On Tue, Sep 17, 2013 at 2:37 PM, Jesse Friedman <highfive at jesserfriedman.com
> wrote:
> I haven't but, I have seen JSON used to do it.
>
>
> On Tue, Sep 17, 2013 at 2:09 PM, Abdussamad Abdurrazzaq <
> abdussamad at abdussamad.com> wrote:
>
> > Don't use curl directly. Use wp_remote_get.
> >
> >
> > On 09/17/2013 08:51 PM, Martin Lazarov wrote:
> >
> >> If you host this file somewhere you can just send link to the plugin
> >> and using curl to download the remote file from the plugin.
> >>
> >> On Tue, Sep 17, 2013 at 6:39 PM, David Anderson <david at wordshell.net>
> >> wrote:
> >>
> >>> Hi,
> >>>
> >>> Has anyone ever written code to send a file, in chunks, from one WP
> >>> install
> >>> to another, using XMLRPC? That's a task I've got to work on soon - but
> I
> >>> don't want to re-invent the wheel.
> >>>
> >>> My plugin code will be installed at both ends.
> >>>
> >>> The files are potentially very large. Basically, the sending end needs
> >>> to be
> >>> able to:
> >>> a) See how much of the file is already uploaded ("oy, how much of this
> >>> file
> >>> have you already got?")
> >>> b) Send the next chunk, in a loop ("here's a chunk - thanks - here's a
> >>> chunk
> >>> - thanks ...")
> >>>
> >>> Many thanks,
> >>> David
> >>>
> >>> --
> >>> WordShell - WordPress fast from the CLI - www.wordshell.net
> >>>
> >>> ______________________________**_________________
> >>> wp-hackers mailing list
> >>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> >>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<
> http://lists.automattic.com/mailman/listinfo/wp-hackers>
> >>>
> >> ______________________________**_________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> >> http://lists.automattic.com/**mailman/listinfo/wp-hackers<
> http://lists.automattic.com/mailman/listinfo/wp-hackers>
> >>
> >> ______________________________**_________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> > http://lists.automattic.com/**mailman/listinfo/wp-hackers<
> http://lists.automattic.com/mailman/listinfo/wp-hackers>
> >
>
>
>
> --
> thanks
> *
> *
> *jesse friedman*
> jes.se.com *
> *
> Book: Web Designers Guide to WordPress -
> http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
> Twitter: @professor <http://twitter.com/professor>
> Facebook: Like<
> https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list