dealnews/storage

此包最新版本(2.0.1)的许可证信息不可用。

对象存储

2.0.1 2024-09-04 01:59 UTC

This package is auto-updated.

Last update: 2024-09-04 02:00:07 UTC


README

此库提供了一个接口,用于从S3等服务存储和检索对象。

use DealNews\ObjectStorage\Storage;
use DealNews\ObjectStorage\Backends\S3;

// the options array for S3 can contain a profile name which will use
// GetConfig to find the other values in dealnews.ini or it can contain
// bucket, region, key, and secret.
$storage = new Storage(S3::init(['profile' => 'get_config_name']));

$object = $storage->store(
    $filename,
    'object/path/name',
    'content/type',
    [
        'meta' => 'data'
    ],
    'public' // ACL setting defaults to bucket default
);

echo json_encode($object, JSON_PRETTY_PRINT);

getheadstore 方法返回一个 DealNews\ObjectStorage\Data\StorageObject 对象。`store` 和 `head` 方法不会在 `object_data` 属性中返回对象的主体。`get` 方法会将对象的主体填充到 `object_data` 属性中。`delete` 方法返回一个布尔值。

{
    "object_storage_id": "QpFqF6v0BO7dhvNPVZO46t5by5lCRrlciL7GH8Quvc0vADZt/UU5zKCu2dHfibdIC33jb2p+fVs=",
    "container": "bucket_name",
    "key": "object/path/name",
    "url_path": "/bucket_name/object/path/name",
    "storage_url": "s3://bucket_name/object/path/name",
    "content_type": "text/plain",
    "meta_data": {
        "Meta": "data"
    },
    "last_modified": "Fri, 13 Aug 2021 21:27:47 GMT",
    "object_data": null
}