Exemple #1
0
    echo '  Error Message: ' . $e->getMessage() . "\n";
}
/*
 * Example #3
 *
 * Upload another file. We're uploading a sample .doc file from the local
 * filesystem using all options.
 */
echo "\n";
echo 'Example #3 - Upload a sample .doc as a file using all options.' . "\n";
$filePath = __DIR__ . '/files/sample.doc';
if (is_file($filePath)) {
    echo '  Uploading... ';
    $handle = fopen($filePath, 'r');
    try {
        $document2 = $boxView->uploadFile($handle, ['name' => 'Sample File #2', 'thumbnails' => ['100x100', '200x200'], 'nonSvg' => true]);
        echo 'success :)' . "\n";
        echo '  ID is ' . $document2->id() . '.' . "\n";
    } catch (Box\View\BoxViewException $e) {
        echo 'failed :(' . "\n";
        echo '  Error Code: ' . $e->errorCode . "\n";
        echo '  Error Message: ' . $e->getMessage() . "\n";
    }
} else {
    echo '  Skipping because the sample .doc file can\'t be found.' . "\n";
}
/*
 * Example #4
 *
 * Check the metadata of the file from Example #3.
 */