dam-bal/vercel-blob-php

Vercel Blob 的 PHP 客户端

1.0.1 2024-04-19 19:16 UTC

This package is auto-updated.

Last update: 2024-09-21 20:36:09 UTC


README

Vercel Blob 存储的 PHP 客户端。

Vercel Blob

安装

composer require dam-bal/vercel-blob-php

用法

创建客户端

$client = new \VercelBlobPhp\Client();

客户端构造函数接受 blob 存储的 token,但如果你已经将 blob 存储连接到项目,则不需要设置它。

使用客户端

PUT

$result = $client->put(
    path: 'test.txt',   // path
    content: 'hello world' // content,
    options: new \VercelBlobPhp\CommonCreateBlobOptions(
        addRandomSuffix: true,      // optional
        contentType: 'text',        // optional
        cacheControlMaxAge: 123,    // optional
    )
);

选项参数是可选的。

DEL

$client->del(['test.txt']);

COPY

$result = $client->copy(
    fromUrl: 'fromUrl',
    toPathname: 'toPathname',
    options: new \VercelBlobPhp\CommonCreateBlobOptions(
        addRandomSuffix: true,      // optional
        contentType: 'text',        // optional
        cacheControlMaxAge: 123,    // optional
    )
);

HEAD

$result = $client->head('url');

LIST

$result = $client->list(
    options: new \VercelBlobPhp\ListCommandOptions(
        limit: 100, // optional
        cursor: 'cursor', // optional
        mode: \VercelBlobPhp\ListCommandMode::EXPANDED, // optional
        prefix: 'prefix', // optional
    )
);

选项参数是可选的。