Beispiel #1
0
    $slave_file_info = $fdfs->storage_upload_slave_by_filebuff('this is slave file  1 by class.', $file_info['group_name'], $master_filename, $prefix_name, $file_ext_name);
    if ($slave_file_info !== false) {
        var_dump($slave_file_info);
        $generated_filename = $fdfs->gen_slave_filename($master_filename, $prefix_name, $file_ext_name);
        if ($slave_file_info['filename'] != $generated_filename) {
            echo "{$slave_file_info['filename']}\n != \n{$generated_filename}\n";
        }
        echo "delete slave file return: " . $fdfs->storage_delete_file($slave_file_info['group_name'], $slave_file_info['filename']) . "\n";
    } else {
        echo "storage_upload_slave_by_filebuff fail, errno: " . $fdfs->get_last_error_no() . ", error info: " . $fdfs->get_last_error_info() . "\n";
    }
    echo "delete file return: " . $fdfs->storage_delete_file($file_info['group_name'], $file_info['filename']) . "\n";
}
$file_id = $fdfs->storage_upload_by_filebuff1("thisisatest.", "bin", array('color' => 'none', 'size' => 0, 'font' => 'Aris'));
if ($file_id) {
    var_dump($fdfs->get_file_info1($file_id));
    echo "file exist: " . $fdfs->storage_file_exist1($file_id) . "\n";
    $ts = time();
    $token = $fdfs->http_gen_token($file_id, $ts);
    echo "token={$token}\n";
    $file_content = $fdfs->storage_download_file_to_buff1($file_id);
    echo "file content: " . $file_content . "(" . strlen($file_content) . ")\n";
    $local_filename = 't4.txt';
    echo 'storage_download_file_to_file1 result: ' . $fdfs->storage_download_file_to_file1($file_id, $local_filename) . "\n";
    echo "storage_set_metadata1 result: " . $fdfs->storage_set_metadata1($file_id, array('color' => 'yellow', 'size' => 32), FDFS_STORAGE_SET_METADATA_FLAG_MERGE) . "\n";
    $master_file_id = $file_id;
    $prefix_name = '.part2';
    $file_ext_name = 'txt';
    $slave_file_id = $fdfs->storage_upload_slave_by_filebuff1('this is slave file 2 by class.', $master_file_id, $prefix_name, $file_ext_name);
    if ($slave_file_id !== false) {
        var_dump($slave_file_id);
}
var_dump(fastdfs_get_file_info1($appender_file_id));
if (!fastdfs_storage_truncate_file1($appender_file_id, 0)) {
    echo "fastdfs_storage_truncate_file1 fail, errno: " . fastdfs_get_last_error_no() . ", error info: " . fastdfs_get_last_error_info() . "\n";
    exit;
}
var_dump(fastdfs_get_file_info1($appender_file_id));
echo "function test done\n\n";
$fdfs = new FastDFS();
$appender_file_id = $fdfs->storage_upload_appender_by_filename1("/usr/include/stdio.h");
if (!$appender_file_id) {
    echo "\$fdfs->storage_upload_appender_by_filename1 fail, errno: " . $fdfs->get_last_error_no() . ", error info: " . $fdfs->get_last_error_info() . "\n";
    exit;
}
var_dump($appender_file_id);
var_dump($fdfs->get_file_info1($appender_file_id));
if (!$fdfs->storage_append_by_filename1("/usr/include/stdlib.h", $appender_file_id)) {
    echo "\$fdfs->storage_append_by_filename1 fail, errno: " . $fdfs->get_last_error_no() . ", error info: " . $fdfs->get_last_error_info() . "\n";
    exit;
}
var_dump($fdfs->get_file_info1($appender_file_id));
if (!$fdfs->storage_modify_by_filename1("/usr/include/stdlib.h", 0, $appender_file_id)) {
    echo "\$fdfs->storage_modify_by_filename1 fail, errno: " . $fdfs->get_last_error_no() . ", error info: " . $fdfs->get_last_error_info() . "\n";
    exit;
}
var_dump($fdfs->get_file_info1($appender_file_id));
if (!$fdfs->storage_truncate_file1($appender_file_id)) {
    echo "\$fdfs->torage_truncate_file1 torage_modify_by_filename1 fail, errno: " . $fdfs->get_last_error_no() . ", error info: " . $fdfs->get_last_error_info() . "\n";
    exit;
}
var_dump($fdfs->get_file_info1($appender_file_id));