bigfs/bigfs-client

BigFS - 云存储客户端

dev-master 2020-07-17 18:24 UTC

This package is not auto-updated.

Last update: 2024-09-22 12:45:11 UTC


README

云存储

此PHP包由OpenAPI Generator项目自动生成

  • API版本:1.0.0
  • 构建包:org.openapitools.codegen.languages.PhpClientCodegen

要求

PHP 5.5及更高版本

安装与使用

Composer

要使用Composer安装绑定,请将以下内容添加到composer.json

{
  "require": {
    "firebase/php-jwt": "5.2.0",
    "bigfs/bigfs-client": "0.1.0"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

    require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

入门指南

请按照安装和用法说明进行操作,然后运行以下命令

<?php

require_once(__DIR__ . '/vendor/autoload.php');
use \Firebase\JWT\JWT;

date_default_timezone_set("UTC");

$jwt_secret = "johndoe";
$now = new DateTime();

$payload = array(
    "nbf" => $now->getTimestamp()
);

$jwt = JWT::encode($payload, $jwt_secret);

$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'Bearer ' . $jwt);

$apiInstance = new OpenAPI\Client\Api\ActivityLogsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

$author = ''; // string | Filter by author
$created_at_system__before = null; // \DateTime | Filter by created_at_system
$created_at_system__after = null; // \DateTime | Filter by created_at_system
$created_at_user__before = null; // \DateTime | Filter by created_at_user
$created_at_user__after = ""; // \DateTime | Filter by created_at_user
$page = 1; // int | Page number
$per_page = 1; // int | Per page row count
$level = 1; // int | log level
$message = null; // string | log message
$object = null; // string | object
$subject = null; // string | log subject
$action = null; // string | log action


try {
    $resultActivityLog = $apiInstance->activityLogsList($author, $created_at_system__before, $created_at_system__after, $created_at_user__before, $created_at_user__after, $page, $per_page, $level, $message, $object, $subject, $action);
    print_r($resultActivityLog);
} catch (Exception $e) {
    echo 'Exception when calling ActivityLogsApi->activityLogsList: ', $e->getMessage(), PHP_EOL;
}

$fileApiInstance = new OpenAPI\Client\Api\FilesApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

$flMetaLabels = array('x' => 'y');
$fileMetaLabelsInstance = array();
$fileMetaLabelsInstance[] = new OpenAPI\Client\Model\FileMetaLabels($flMetaLabels);

$fl = array();
$fl['name'] = 'new_img.png';
$fl['labels'] = $fileMetaLabelsInstance;

$fileMetaInstance = new OpenAPI\Client\Model\FileMeta($fl);

try {
    $result = $fileApiInstance->create($fileMetaInstance);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling FilesApi->create: ', $e->getMessage(), PHP_EOL;
}

$file1 = new SPLFileObject('./splitonfivemegabytesaa');
$file2 = new SPLFileObject('./splitonfivemegabytesab');

try {
    $resultUpload1 = $fileApiInstance->uploadContent($result['file_id'], $file1, 1, 'bytes=0-5242880');
} catch (Exception $e) {
    echo 'Exception when calling FilesApi->uploadContent: ', $e->getMessage(), PHP_EOL;
}

try {
    $resultUpload2 = $fileApiInstance->uploadContent($result['file_id'], $file2, 2, 'bytes=5242881-6609827');
} catch (Exception $e) {
    echo 'Exception when calling FilesApi->uploadContent: ', $e->getMessage(), PHP_EOL;
}

$parts = array();
$parts['parts'] = [1, 2];
$multipartUploadInstance = new OpenAPI\Client\Model\MultipartUpload($parts);

try {
    $resultCompleteUpload = $fileApiInstance->completeMultipartUpload($result['file_id'], $multipartUploadInstance);
} catch (Exception $e) {
    echo 'Exception when calling FilesApi->completeMultipartUpload: ', $e->getMessage(), PHP_EOL;
}

$xCloudStorageVersion = 1;

try {
    $resultGet = $fileApiInstance->get($result['file_id'], "bytes=0-3609000", $xCloudStorageVersion);
} catch (Exception $e) {
    echo 'Exception when calling FilesApi->completeMultipartUpload: ', $e->getMessage(), PHP_EOL;
}

$ouput = '';
while (!$resultGet->eof()) {
    $output .= $resultGet->fgets();
}

$file = new SplFileObject("new_img.png", 'w+');
$file->fwrite($output);

?>

API端点文档

所有URI均相对于https://storage.example.com/v1

模型文档

授权文档

Bearer

  • 类型:API密钥
  • API密钥参数名称:Authorization
  • 位置:HTTP头

作者

support@bigfs.cloud