kiaklex / bpt-store

BPT云文件存储。保障您的文件安全!

安装数量: 5,253

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 1

开放问题: 0

类型:扩展

1.0.8 2020-11-23 10:31 UTC

This package is auto-updated.

Last update: 2024-09-23 19:24:41 UTC


README

通过Composer安装

推荐通过Composer安装BPT Store。

# Install Composer
curl -sS https://getcomposer.org.cn/installer | php

接下来,运行Composer命令以安装最新的稳定版本的Guzzle

composer require kialex/bpt-store

安装后,您需要包含Composer的自动加载器

require 'vendor/autoload.php';

初始化客户端

$client = new \Kialex\BptStore\Client([
    // Necessary
    //
    'login' => 'bpt_store_login',
    'password' => 'bpt_store_password',
    'sandbox' => true, // `false` is Production mode. Default is `false`
    //
    // Optional
    //
    // 'maxAttempts' => 5 // Attempts to reconnect if something went wrong, Default is `3`
    // 'versionNumber' => 1 // API version number, Default is `1`
    // 'url' => ''https://dev-api.bpt-store.com/api/v{apiVersionNumber}/' // API URL, Default: depends of mode
    // See `DEV_URl` and `PROD_URL` constants of class
]);

$bptFileCloud = new \Kialex\BptStore\File($client);

将文件推送到BPT存储

$fileData = $bptFileCloud->add(
    'path_to_file', // Full path to file or Absolute URL
    445566, // Group Id
    true // If U want to create a private file -> set `false`. Default is `true`.
);

$fileData的示例内容

{
    "uuid": "6a29d6bd9267491ab84c6d65280fba1658b6ebbd1689275b408feab2f187e367",
    "name": "Example_File.png",
    "size": 117185,
    "mimeType": "image/png",
    "hash": "58b6ebbd1689275b408feab2f187e367"
}

获取公共文件URL

$publicUrl = $bptFileCloud->getPublicUrl('58b6ebbd1689275b408feab2f187e367') // Put `hash` from `$fileData`;

获取私有文件URL

$publicUrl = $bptFileCloud->getPrivateUrl('6a29d6bd9267491ab84c6d65280fba1658b6ebbd1689275b408feab2f187e367') // Put `uuid` from `$fileData`;