定制 reactphp-x/filesystem-s3 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

reactphp-x/filesystem-s3

最新稳定版本:v1.0.1

Composer 安装命令:

composer require reactphp-x/filesystem-s3

包简介

README 文档

README

install

composer require reactphp-x/filesystem-s3 -vvv

usage

<?php

require __DIR__.'/../vendor/autoload.php';

use ReactphpX\FilesystemS3\Adapter;
use React\EventLoop\Loop;
use React\Filesystem\Node\FileInterface;
use React\Filesystem\Node\DirectoryInterface;

// 初始化 S3 适配器
$bucket = 'xxxx';
$adapter = new Adapter([
    'endpoint' => 'xxxx',
    'version' => 'latest',
    'region'  => 'us-east-1',
    'use_path_style_endpoint' => true,
    'credentials' => [
        'key'    => 'xxx',
        'secret' => 'xxxx',
    ],
], $bucket);

// 示例:上传文件
$destinationPath = 'uploads/example.txt';


$adapter->file($destinationPath)->putContents('Hello World!')->then(function () use ($adapter, $destinationPath) {
    echo "File uploaded to S3: $destinationPath\n";
}, function ($error) {
    echo "Error uploading file: " . $error->getMessage() . "\n";
});

// 示例:读取文件

$adapter->file($destinationPath)->getContents()->then(function ($content) {
    echo "File content: $content\n";
}, function ($error) {
    echo "Error reading file: " . $error->getMessage() . "\n";
});

// 示例:删除文件

// $adapter->file($destinationPath)->unlink()->then(function () use ($adapter, $destinationPath) {
//     echo "File deleted from S3: $destinationPath\n";
// }, function ($error) {
//     echo "Error deleting file: " . $error->getMessage() . "\n";
// });

// 示例:列出目录

$adapter->directory('')->ls()->then(function ($nodes) {
    foreach ($nodes as $node) {
        if ($node instanceof FileInterface) {
            echo "File: " . $node->path() . "\n";
        } elseif ($node instanceof DirectoryInterface) {
            echo "Directory: " . $node->path() . "\n";
        }
    }
}, function ($error) {
    echo "Error listing directory: " . $error->getMessage() . "\n";
});

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固