예제 #1
0
function createFolder()
{
    $folder = new StorageAPIs($_SESSION['sHost'], $_SESSION['sApp'], $_SESSION['sTr']);
    echo "\nCREATE FOLDER: \n\n";
    $var0 = trim($_POST['var0'], " ");
    $var1 = trim($_POST['var1'], " ");
    $var2 = trim($_POST['var2'], " ");
    if (strlen($var0) == 0 || strlen($var1) == 0) {
        echo "\n Error: Empty mandatory field(s)!\n";
    } else {
        $folder->setAuthToken($var0);
        if (strlen($var2) == 0) {
            $responseObject = $folder->createFolder($var1);
        } else {
            $responseObject = $folder->createFolder($var1, $var2);
        }
        $current = $responseObject->getErrorStatus();
        if (!empty($current)) {
            echo "Error Status: \n";
            echo " Error code: " . $current->getCode() . "\n";
            echo " Error message: " . $current->getMessage() . "\n";
        } else {
            $current = $responseObject->getRevision();
            if (!empty($current)) {
                echo " Revision: " . $current . "\n";
            } else {
                echo " Revision: N/A\n";
            }
            $current = $responseObject->getId();
            if (!empty($current)) {
                echo " Id: " . $current . "\n";
            } else {
                echo " Id: N/A\n";
            }
            $current = $responseObject->getCreatedOn();
            if (!empty($current)) {
                echo " Created On: " . $current . "\n";
            } else {
                echo " Created On: N/A\n";
            }
            $current = $responseObject->getFileCount();
            if (strlen($current) == 0) {
                echo " File Count: N/A\n";
            } else {
                echo " File Count: " . $current . "\n";
            }
            $current = $responseObject->getFolderCount();
            if (strlen($current) == 0) {
                echo " Folder Count: N/A\n";
            } else {
                echo " Folder Count: " . $current . "\n";
            }
            $current = $responseObject->getName();
            if (strlen($current) == 0) {
                echo " Name: N/A\n";
            } else {
                echo " Name: " . $current . "\n";
            }
            $current = $responseObject->getParentId();
            if (strlen($current) == 0) {
                echo " Parent Id: N/A\n";
            } else {
                echo " Parent Id: " . $current . "\n";
            }
            $current = $responseObject->getReadable();
            if (strlen($current) == 0) {
                echo " Readable: N/A\n";
            } else {
                echo " Readable: " . $current . "\n";
            }
            $current = $responseObject->getSize();
            if (strlen($current) == 0) {
                echo " Size: N/A\n";
            } else {
                echo " Size: " . $current . "\n";
            }
            $current = $responseObject->getType();
            if (!empty($current)) {
                echo " Type: " . $current . "\n";
            } else {
                echo " Type: N/A\n";
            }
            $current = $responseObject->getUpdatedOn();
            if (!empty($current)) {
                echo " Updated On: " . $current . "\n";
            } else {
                echo " Updated On: N/A\n";
            }
            $current = $responseObject->getWritable();
            if (strlen($current) == 0) {
                echo " Writable: N/A\n";
            } else {
                echo " Writable: " . $current . "\n";
            }
            $files = $responseObject->getFiles();
            if (!empty($files)) {
                echo "\nFiles: \n";
                foreach ($files as $file) {
                    $current = $file->getRevision();
                    if (!empty($current)) {
                        echo " Revision: " . $current . "\n";
                    } else {
                        echo " Revision: N/A\n";
                    }
                    $current = $file->getId();
                    if (!empty($current)) {
                        echo " Id: " . $current . "\n";
                    } else {
                        echo " Id: N/A\n";
                    }
                    $current = $file->getCreatedOn();
                    if (!empty($current)) {
                        echo " Created On: " . $current . "\n";
                    } else {
                        echo " Created On: N/A\n";
                    }
                    $current = $file->getName();
                    if (!empty($current)) {
                        echo " Name: " . $current . "\n";
                    } else {
                        echo " Name: N/A\n";
                    }
                    $current = $file->getParentId();
                    if (strlen($current) == 0) {
                        echo " Parent Id: N/A\n";
                    } else {
                        echo " Parent Id: " . $current . "\n";
                    }
                    $current = $file->getSize();
                    if (!empty($current)) {
                        echo " Size: " . $current . "\n";
                    } else {
                        echo " Size: N/A\n";
                    }
                }
            } else {
                echo "\nFiles: N/A\n";
            }
        }
    }
    echo "\n----------------------------------------------------------------------------------------------------\n";
}
예제 #2
0
 public function create_folder($name = null, $parentid = 'default')
 {
     $out = array();
     if (strlen($name) == 0) {
         $this->errormessage = 'Empty mandatory field(s)!';
         return false;
     }
     $folder = new \StorageAPIs(\Session::get('ysi.sHost'), \Session::get('ysi.sApp'), \Session::get('ysi.sTr'));
     $folder->setAuthToken(\Session::get('ysi.sToken'));
     if ($parentid == 'default') {
         $response = $folder->createFolder($name, \Config::get('yousendit.default_folder_id'));
     } elseif (is_numeric($parentid)) {
         $response = $folder->createFolder($name, $parentid);
     } else {
         $response = $folder->createFolder($name);
     }
     $current = $response->getErrorStatus();
     if (!empty($current)) {
         $this->errorcode = $current->getMessage();
         $this->errormessage = $current->getCode();
         return false;
     } else {
         return $response;
     }
     return false;
     exit;
     if (strlen($var2) == 0) {
         $responseObject = $folder->createFolder($var1);
     } else {
         $responseObject = $folder->createFolder($var1, $var2);
     }
     $current = $responseObject->getErrorStatus();
     if (!empty($current)) {
         echo "Error Status: \n";
         echo " Error code: " . $current->getCode() . "\n";
         echo " Error message: " . $current->getMessage() . "\n";
     } else {
         $current = $responseObject->getRevision();
         if (!empty($current)) {
             echo " Revision: " . $current . "\n";
         } else {
             echo " Revision: N/A\n";
         }
         $current = $responseObject->getId();
         if (!empty($current)) {
             echo " Id: " . $current . "\n";
         } else {
             echo " Id: N/A\n";
         }
         $current = $responseObject->getCreatedOn();
         if (!empty($current)) {
             echo " Created On: " . $current . "\n";
         } else {
             echo " Created On: N/A\n";
         }
         $current = $responseObject->getFileCount();
         if (strlen($current) == 0) {
             echo " File Count: N/A\n";
         } else {
             echo " File Count: " . $current . "\n";
         }
         $current = $responseObject->getFolderCount();
         if (strlen($current) == 0) {
             echo " Folder Count: N/A\n";
         } else {
             echo " Folder Count: " . $current . "\n";
         }
         $current = $responseObject->getName();
         if (strlen($current) == 0) {
             echo " Name: N/A\n";
         } else {
             echo " Name: " . $current . "\n";
         }
         $current = $responseObject->getParentId();
         if (strlen($current) == 0) {
             echo " Parent Id: N/A\n";
         } else {
             echo " Parent Id: " . $current . "\n";
         }
         $current = $responseObject->getReadable();
         if (strlen($current) == 0) {
             echo " Readable: N/A\n";
         } else {
             echo " Readable: " . $current . "\n";
         }
         $current = $responseObject->getSize();
         if (strlen($current) == 0) {
             echo " Size: N/A\n";
         } else {
             echo " Size: " . $current . "\n";
         }
         $current = $responseObject->getType();
         if (!empty($current)) {
             echo " Type: " . $current . "\n";
         } else {
             echo " Type: N/A\n";
         }
         $current = $responseObject->getUpdatedOn();
         if (!empty($current)) {
             echo " Updated On: " . $current . "\n";
         } else {
             echo " Updated On: N/A\n";
         }
         $current = $responseObject->getWritable();
         if (strlen($current) == 0) {
             echo " Writable: N/A\n";
         } else {
             echo " Writable: " . $current . "\n";
         }
         $files = $responseObject->getFiles();
         if (!empty($files)) {
             echo "\nFiles: \n";
             foreach ($files as $file) {
                 $current = $file->getRevision();
                 if (!empty($current)) {
                     echo " Revision: " . $current . "\n";
                 } else {
                     echo " Revision: N/A\n";
                 }
                 $current = $file->getId();
                 if (!empty($current)) {
                     echo " Id: " . $current . "\n";
                 } else {
                     echo " Id: N/A\n";
                 }
                 $current = $file->getCreatedOn();
                 if (!empty($current)) {
                     echo " Created On: " . $current . "\n";
                 } else {
                     echo " Created On: N/A\n";
                 }
                 $current = $file->getName();
                 if (!empty($current)) {
                     echo " Name: " . $current . "\n";
                 } else {
                     echo " Name: N/A\n";
                 }
                 $current = $file->getParentId();
                 if (strlen($current) == 0) {
                     echo " Parent Id: N/A\n";
                 } else {
                     echo " Parent Id: " . $current . "\n";
                 }
                 $current = $file->getSize();
                 if (!empty($current)) {
                     echo " Size: " . $current . "\n";
                 } else {
                     echo " Size: N/A\n";
                 }
             }
         } else {
             echo "\nFiles: N/A\n";
         }
     }
 }