Example #1
0
if ($token == '') {
    jsonreply(array('fail' => 'Auth token cannot be blank'));
}
$username = '';
try {
    $username = trim(param_variable('username'));
} catch (ParameterException $e) {
}
if ($username == '') {
    jsonreply(array('fail' => 'Username cannot be blank'));
}
// Starting the creation of our artefact (file) object
$data = new StdClass();
$USER = new User();
try {
    $USER->find_by_mobileuploadtoken($token, $username);
} catch (AuthUnknownUserException $e) {
    jsonreply(array('fail' => 'Invalid user token'));
}
$data->owner = $USER->get('id');
// id of owner
$folder = '';
try {
    $folder = param_variable('foldername');
    $folder = trim($folder);
    if ($folder) {
        // TODO: create if doesn't exist - note assumes it is a base folder (hence null parent)
        $artefact = ArtefactTypeFolder::get_folder_by_name($folder, null, $data->owner);
        // id of folder you're putting the file into
        if ($artefact) {
            $data->parent = $artefact->id;