railroad/remotestorage
Composer 安装命令:
composer require railroad/remotestorage
包简介
Remote storage service
README 文档
README
Wrapper for slightly easier use of league/flysystem with AWS S3 by our Laravel application.
Installation, Configuration, Use
Installation
Run $ composer vendor:publish to copy the package's configuration file "/config/remotestorage.php" to your application's "/config" directory.
(assuming you're using Composer, Laravel, and AWS S3)
Configuration
Define the following environmental variables with appropriate values:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
- AWS_BUCKET
Add the service provider (\Railroad\RemoteStorage\Providers\RemoteStorageServiceProvider) to the 'providers array in you application's /config/app.php:
'providers' => [ # ... \Railroad\RemoteStorage\Providers\RemoteStorageServiceProvider::class, ]
Run $ php artisan vendor:publish to copy the config file and create a remotestorage.php file in your application's /config directory. This will take the values you supplied in the .env file and pass them needed.
Use
Inject the Railroad\RemoteStorage\Services\RemoteStorageService class where needed
/** @var Railroad\RemoteStorage\Services\RemoteStorageService $remoteStorageService */ protected $remoteStorageService; public function __constructor(Railroad\RemoteStorage\Services\RemoteStorageService $remoteStorageService){ $this->remoteStorageService = $remoteStorageService; }
Include namespace at top of file:
use Railroad\RemoteStorage\Services;
... to save yourself having to specify the namespace everywhere:
/** @var RemoteStorageService $remoteStorageService */ protected $remoteStorageService; public function __constructor(RemoteStorageService $remoteStorageService){ $this->remoteStorageService = $remoteStorageService; }
Responses
| outcome | return data type | return data value |
|---|---|---|
| succeeded | boolean | true |
| failed | boolean | false |
read
Usage Example(s)
$file = $this->remoteStorageService->read($filenameRelative);
Parameters
| # | name | required | type | description |
|---|---|---|---|---|
| 1 | filenameRelative | yes | string | path to file name from bucket root |
Responses
| outcome | return data type | return data value (example) | notes about return data |
|---|---|---|---|
| failed | boolean | false | |
| succeeded | string | "b"""Ø à\x00\x10JFIF\x00\x01\x01\x01\x00\x00\x00\x00 ■\x00;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 70\n █\x00C\x00\n\x07\x07\x08\x07\x06\n\x08\x08\x08\v\n\n" |
Raw image data as string |
exists
Usage Example(s)
$exists = $this->remoteStorageService->exists('foo/bar.jpg');
/** * @param Request $request * @return JsonResponse */ public function uploadThumbnailIfDoesNotAlreadyExist(Request $request) { $target = 'foo/' . $request->get('target'); if(!$this->remoteStorageService->exists('foo/')){ $upload = $this->remoteStorageService->put($target, $request->file('file')); throw_if((!$upload), new JsonResponse('Upload product thumbnail failed', 400)); } return new JsonResponse(['exists' => true]); }
Parameters
| # | name | required | type | description |
|---|---|---|---|---|
| 1 | filenameRelative | yes | string | path to file name from bucket root |
Responses
| outcome | return data type | return data value |
|---|---|---|
| exists | boolean | true |
| does not exist | boolean | false |
delete
Usage Example(s)
$this->remoteStorageService->delete('foo/bar.jpg');
public function deleteThumbnail(Request $request) { $target = $request->get('target'); $delete = $this->remoteStorageService->delete('foo/' . $target); throw_if((!$delete), new JsonResponse('product thumbnail deletion failed', 400)); return new JsonResponse(['deleted' => true]); }
Parameters
| # | name | required | type | description |
|---|---|---|---|---|
| 1 | filenameRelative | yes | string | path to file name from bucket root |
Responses
| outcome | return data type | return data value |
|---|---|---|
| exists | boolean | true |
| does not exist | boolean | false |
create_dir
[TODO]
rename
[TODO]
copy
[TODO]
get_mimetype
[TODO]
get_timestamp
[TODO]
get_size
[TODO]
delete_dir
[TODO]
railroad/remotestorage 适用场景与选型建议
railroad/remotestorage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85.04k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 railroad/remotestorage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 railroad/remotestorage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 85.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-03-11