linkorb / filespace
面向最终用户的灵活存储解决方案
v1.3.0
2015-05-09 10:39 UTC
Requires
- php: >=5.3.0
- linkorb/objectstorage: ~2.0
- phpseclib/phpseclib: ~0.3
Requires (Dev)
- aws/aws-sdk-php: ~2.7
- doctrine/dbal: ~2.4
- linkorb/database-manager: dev-master
- symfony/console: ~2.4
This package is auto-updated.
Last update: 2024-09-10 12:07:02 UTC
README
面向最终用户的灵活存储解决方案。
查看我们的博客文章,了解我们在生产环境中如何使用它:http://engineering.linkorb.com/blog/scaling-user-data-with-objectstorage-in-php
安装
查看composer以获取有关安装和运行composer的详细信息。
然后,将linkorb/filespace
添加到您的项目composer.json
{ "require": { "linkorb/filespace": "~1.0" } }
用法
use Aws\S3\S3Client; use FileSpace\Service\PdoService; use ObjectStorage\Adapter\S3Adapter; // Instantiate an S3 connection $s3client = S3Client::factory(array( 'key' => 'my_s3_key', 'secret' => 'my_s3_secret' )); // Get a storage adapter based on the s3 client $storage = new S3Adapter($s3client, 'my-bucket-name', 'my/key/prefix/'); // Get a PDO connection $pdo = ... // TODO; // Instantiate the File Space Service: $service = new PdoFileSpaceService($pdo, $storage); // test if a 'space' has been created: $space_key = 'account-x.contact.c001'; if (!$service->hasSpace($space_key)) { $service->createSpace($space_key, "Customer 1: John Johnson"); } $space = $service->getSpace($space_key); // List all files in the space $files = $service->getFiles($space); foreach ($files as $file) { echo $file->getKey() . ': ' . $file->getSizeOriginalDisplay() . "\n"; } // Upload a file into this space $service->upload($space, 'contract-final.pdf', '/home/john/Downloads/contract.pdf'); // Download a file from this space: $service->download($space, 'invoice-1234.pdf', '/home/john/invoices/invoice-1234.pdf'); // Delete a file from the space: $service->deleteFile($space, 'remove-me.txt');
初始化数据库模式
vendor/bin/database-manager database:loadschema --apply filespace example/schema.xml
贡献
准备好构建和改进这个存储库了吗?太好了!请fork/clone这个存储库,我们期待您的pull请求!
如果您无法实现您喜欢的更改,请不要犹豫,打开一个新的问题报告,这样我们或其他人可以处理它。
由LinkORB工程团队提供
查看我们的其他项目linkorb.com/engineering。
顺便说一句,我们在招聘!
许可
请查看LICENSE.md以获取完整的许可信息