$postData = array('operation' => 'mkdir', 'repo-id' => $repoid, 'token' => self::$token, 'p' => $remoteDir);
$data = self::request ( "$url/api2/repos/$repoid/dir/", true, $postData );
08-03-2014 12:51:12] https://cloud.seafile.com//api2/auth-token/
[08-03-2014 12:51:12]
array (
'username' => 'in...@mydomain.com',
'password' => 'thisismypassword',
)[08-03-2014 12:51:23] https://cloud.seafile.com//api2/repos/693c5bee-438f-42ba-b2dc-1fb13c82fd44/dir/
[08-03-2014 12:51:23]
array (
'operation' => 'mkdir',
'repo-id' => '693c5bee-438f-42ba-b2dc-1fb13c82fd44',
'token' => 'b7fd611e119b49ea1c27405c41bf584e1e80267e',
'p' => '/documents/2013/Invoices/2/May/',
)
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'rest_curl_client.php');
$c = new RestCurlClient();
$json_auth_token = json_decode($c->post('http://<your_url>:8000/api2/auth-token/',
array('username'=>'m...@email.com', 'password'=>'test123')));
echo 'Token: <pre>';
print_r($json_auth_token);
$token = (string)$json_auth_token->token;
$json_repos = json_decode($c->get('http://<your_url>:8000/api2/repos/', array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token))
));
echo '</pre>Repos:<pre>';
print_r($json_repos);
$upload_link = json_decode($c->get('http://<your_url>:8000/api2/repos/'.$json_repos[0]->id.'/upload-link/', array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token))
));
echo '</pre>Upload Link:<pre>';
var_dump($upload_link);
$uploadhash = $c->post($upload_link, array('file'=>new CurlFile(dirname(__FILE__).DIRECTORY_SEPARATOR.'test.php', 'text/plain', 'test.php'), 'filename'=>'test.php', 'parent_dir'=>'/'), array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token, 'Expect:')));
echo '</pre>Upload hash:<pre>';
print_r($uploadhash);
?>
--
You received this message because you are subscribed to a topic in the Google Groups "seafile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/seafile/d7XPqpmVrvY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to seafile+u...@googlegroups.com.
To post to this group, send email to sea...@googlegroups.com.
Visit this group at http://groups.google.com/group/seafile.
For more options, visit https://groups.google.com/d/optout.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'rest_curl_client.php');
$c = new RestCurlClient();
$json_auth_token = json_decode($c->post('http://<your_url>:8000/api2/auth-token/',
array('username'=>'m...@email.com', 'password'=>'test123')));
echo 'Token: <pre>';
print_r($json_auth_token);
$token = (string)$json_auth_token->token;
$json_repos = json_decode($c->get('http://<your_url>:8000/api2/repos/', array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token))
));
echo '</pre>Repos:<pre>';
print_r($json_repos);
$upload_link = json_decode($c->get('http://<your_url>:8000/api2/repos/'.$json_repos[0]->id.'/upload-link/', array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token))
));
echo '</pre>Upload Link:<pre>';
var_dump($upload_link);
$uploadhash = $c->post($upload_link, array('file'=>new CurlFile(dirname(__FILE__).DIRECTORY_SEPARATOR.'test.php', 'text/plain', 'test.php'), 'filename'=>'test.php', 'parent_dir'=>'/'), array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token, 'Expect:')));
echo '</pre>Upload hash:<pre>';
print_r($uploadhash);?>
I hope this helps.
$dirpath = '/your_directory_name';
$data = json_decode($c->post('http://<your_url>:8000/api2/repos/'.$json_repos[0]->id.'/dir/?p='.$dirpath,
array('operation'=>'mkdir'), array(CURLOPT_HTTPHEADER=>array('Authorization: Token '.$token))));
http://<your_url>:8000/api2/repos/<repo-id>/dir/?p=/<your_new_directory_name>
Then set the post parameter key 'operation' with value 'mkdir'.
Afterwards add the entry 'Authorization: Token <your_auth_token>' to the headers being sent. <- This step is mandatory for every request!
Execute the POST request.
If everything goes well, you should receive the message 'success' from the api.