Dashboard > Directory > API Profile
525 of 962 APIs    « Previous Next »

Open Xdrive API

  
1. Posted 22 Feb 2008 by net
You can use simple perl script to upload files to xdrive.
------begin--------
#!/usr/bin/perl

use LWP::UserAgent;
use JSON;
use Data::Dumper;

my $json = JSON->new(pretty => 1, delimiter => 0);
my $ua = LWP::UserAgent->new;

$numArgs = $#ARGV ;
if ($numArgs < 2) {
print "Usage: <program> username password filenamern";
exit -1;
}

$USER=$ARGV[0];
$PASSWD=$ARGV[1];
$FILENAME=$ARGV[2];

$credentials = {"user" => {
"type" => "MemberObject",
"username" => $USER,
"password" => $PASSWD
}};

$json_req = $json->objToJson($credentials);
$url="https://plus.xdrive.com/json/v1.2/member.login?data=$json_req";
$response = $ua->post($url);
$content = $response->content;
$obj = $json->jsonToObj($content);
print Dumper $obj;
$JSESSIONID=$obj->{jsessionid};
$ROOT_DIR=$obj->{results}->{user}->{rootFolderId};


$req = {
"destFolder" => {
"type" => "FileObject",
"id" => $ROOT_DIR },
};
$json_req = $json->objToJson($req);

$url = "http://plus.xdrive.com/json/v1.2/io.formupload;jsessionid=$JSESSIONID?data=$json_req";
$response = $ua->post($url,
'Content_Type' => "multipart/form-data",
'Content' => ['file' => [$FILENAME]],
);
$content = $response->content;

$obj = $json->jsonToObj($content);
print Dumper $obj;

----------end---------
Feel free to add your comments.

 


 

ProgrammableWeb Sponsors

Build mashups at openkapowCreate Voice Mashups, Win Money at BroadSoft SnapLogic - Integrate SaaS TodayMonetize your music spaceWeb 2.0 Expo Europe, Berlin Oct 21-23
Develop and deploy. Wicked, Fast, Free. BungeeConnect


 

 

 

 
 
© ProgrammableWeb.com 2008. All rights reserved.
Terms of Service | Privacy Policy