vortos/vortos-object-store
最新稳定版本:v1.0.0-alpha-126
Composer 安装命令:
composer require vortos/vortos-object-store
包简介
Vortos object storage — S3-compatible storage with first-class Cloudflare R2 defaults
README 文档
README
S3-compatible object storage with Cloudflare R2 defaults, transactional outbox, direct-to-cloud uploads, and server-side multipart transfers.
Design
- User file uploads go directly to R2/S3 via presigned URLs. The backend issues a signed URL, stores the object key, and promotes from
tmp/to a permanent key after validation. - Mutations (put, delete, copy, move) are queued through the outbox so file adoption is atomic with domain DB changes.
tmp/keys are cleaned up by a bucket lifecycle rule managed viavortos:object-store:lifecycle.- Integration tests run against real R2/S3 credentials. LocalStack is not part of this package.
Configuration
use Vortos\ObjectStore\DependencyInjection\VortosObjectStoreConfig; return static function (VortosObjectStoreConfig $config): void { $config ->driver('s3') ->provider('r2') ->region('auto') ->bucket($_ENV['OBJECT_STORE_BUCKET']); $config->client() ->accountId($_ENV['OBJECT_STORE_ACCOUNT_ID']) ->credentials($_ENV['OBJECT_STORE_ACCESS_KEY_ID'], $_ENV['OBJECT_STORE_SECRET_ACCESS_KEY']); $config->bucketConfig() ->temporaryKeyPrefix('tmp') ->publicBaseUrl($_ENV['OBJECT_STORE_PUBLIC_BASE_URL'] ?? null) ->maxUploadSizeBytes(5_368_709_120) ->maxPresignTtlSeconds(3600); $config->lifecycle() ->enabled(true) ->requireConfirmation(true); };
Service Guarantees
The injected interface defines the delivery guarantee. There is no hidden config switch.
// Business workflows: outbox row is atomic with domain DB changes. // Use only inside CommandBus command handlers. DirectUploadManagerInterface $uploads; ObjectStoreInterface $objects; // Maintenance workflows: outbox reliability, but only the outbox row is transactional. StandaloneDirectUploadManagerInterface $uploads; StandaloneObjectStoreInterface $objects; // Diagnostics and probes: direct provider call, no outbox. ImmediateDirectUploadManagerInterface $uploads; ImmediateObjectStoreInterface $objects;
Direct Upload Flow
- Call
DirectUploadManagerInterface::createUploadIntent()for atmp/...key. - The client uploads directly to R2/S3 using the returned signed URL.
- Persist domain data with the temporary key.
- After validation, call
promote()— copies to a permanent key, optionally deletes the source.
Server-Side Multipart
ServerSideMultipartUploadManagerInterface handles backend-owned transfers: imports, exports, migrations, CLI jobs. It validates S3 part limits, keeps memory bounded by part size, retries transient part failures, and aborts failed uploads. Do not use it for browser uploads — use the direct-to-cloud flow above.
Lifecycle Provisioning
Lifecycle rules are never applied during HTTP requests, workers, or container boot.
php bin/console vortos:object-store:lifecycle show php bin/console vortos:object-store:lifecycle plan php bin/console vortos:object-store:lifecycle apply --confirm php bin/console vortos:object-store:lifecycle remove --confirm
The managed rule ID defaults to vortos-object-store-expire-temporary-uploads. The manager upserts only that rule, preserves unrelated rules, and writes the merged lifecycle config back through the S3 API.
Commands
php bin/console vortos:object-store:head <key> php bin/console vortos:object-store:presign <key> php bin/console vortos:object-store:presign <key> --upload --content-type=video/mp4 --max-size=209715200 php bin/console vortos:object-store:relay php bin/console vortos:object-store:lifecycle <show|plan|apply|remove> php bin/console vortos:object-store:multipart list --prefix=imports/ php bin/console vortos:object-store:multipart abort --key=imports/big.csv --upload-id=<id> --confirm php bin/console vortos:object-store:multipart abort-stale --older-than="-24 hours" --dry-run php bin/console vortos:worker:install --worker=object-store-outbox-relay
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-28