johnlui / aliyunoss Goto Github PK
View Code? Open in Web Editor NEW阿里云 OSS 官方 SDK 的 Composer 封装,支持任何 PHP 项目,包括 Laravel、Symfony、TinyLara 等等。
阿里云 OSS 官方 SDK 的 Composer 封装,支持任何 PHP 项目,包括 Laravel、Symfony、TinyLara 等等。
在AliyunOSS 中, 传入的$file 其实是 filepath, 源代码中只有fread, 没有fclose. 建议这里改动一下api, 直接传入 file 的 source对象, , 让调用这个api的逻辑 自己去处理 fopen 和fclose...
public function uploadFile($key, $file)
{
$file_content = fopen($file, 'rb');
$result = $this->ossClient->putObject(array(
'Bucket' => $this->bucket,
'Key' => $key,
'Content' =>$file_content,
'ContentLength' => filesize($file)
));
fclose($file_content);
return $result;
}
封装后对阿里云缺少了不少功能,例如Object的删除,以及大文件的分块上传等。
这几个功能用的还是比较多的。建议AliyunOSS.php类里面添加新的函数。
Argument 1 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an object, string given,
请问,私有服务的读取URL签名怎么使用
能不能做成provider的方式自动加载
RuntimeException in FilesystemAdapter.php line 322: This driver does not support retrieving URLs.
你好,请问可以加个文件的元信息的访问方法吗,或者给个push权限,我提个pull request。我加了却发现没权限push @johnlui
您好,以前使用一直正常,今天出现:local.ERROR: exception 'ErrorException' with message 'SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '<' not found',请问什么原因呢?信息!
putObject
方法可传四个参数,第四个参数$options
,传入数组 ['Cache-Control'=>'max-age=1000']
为何不生效?
运行的时候提示这个,不知道什么原因
没有看到有支持设置obj的acl方法
调用getPrivateObjectURLWithExpireTime方法获取资源,访问资源oss出现SignatureDoesNotMatch
AccessDenied
Request has expired.
589A7A90CDF4741F7D36F2F4
ws-img-test.oss-cn-hangzhou.aliyuncs.com
2017-02-07T01:30:29.000Z
2017-02-08T01:55:28.000Z
输入正确的bucket明, 我dd构造的ossClient, bucket返回null不管输入正确的还是错误的key与Secret,
AliyunOSS {#226 ▼
#ossClient: OSSClient {#233 ▶}
#bucket: null
}
/**
/**
/**
/**
* 使用外网上传文件
* @param string bucket名称
* @param string 上传之后的 OSS object 名称
* @param string 删除文件路径
* @return boolean 上传是否成功
*/
public static function publicUpload($bucketName, $ossKey, $filePath, $options = [])
{
$oss = new self();//这里改写
$oss->ossClient->setBucket($bucketName);
return $oss->ossClient->uploadFile($ossKey, $filePath, $options);
}
当前我上传文件是前端ajax传递到控制器的(文件可能偏大),所以前端就有上传进度展示的需求了。
所以我的问题是:怎么去获取文件当前上传到OSS的进度呢?
Argument 1 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an object, string given, called in /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/libs/guzzle/common/Guzzle/Common/AbstractHasDispatcher.php on line 41
"error_trance": "#0 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/libs/guzzle/common/Guzzle/Common/AbstractHasDispatcher.php(41): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('client.create_r...', Object(Guzzle\Common\Event))\n#1 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/libs/guzzle/http/Guzzle/Http/Client.php(450): Guzzle\Common\AbstractHasDispatcher->dispatch('client.create_r...', Array)\n#2 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/libs/guzzle/http/Guzzle/Http/Client.php(199): Guzzle\Http\Client->prepareRequest(Object(Guzzle\Http\Message\EntityEnclosingRequest), Array)\n#3 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/Common/Communication/HttpServiceClient.php(119): Guzzle\Http\Client->createRequest('PUT', 'https://os-img-...', Array, Object(Guzzle\Http\ReadLimitEntityBody))\n#4 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/Common/Communication/HttpServiceClient.php(56): Aliyun\Common\Communication\HttpServiceClient->buildCoreRequest(Object(Aliyun\Common\Communication\HttpRequest))\n#5 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/Common/Communication/OpenServiceClient.php(37): Aliyun\Common\Communication\HttpServiceClient->sendRequest(Object(Aliyun\Common\Communication\HttpRequest), Object(Aliyun\Common\Communication\ExecutionContext))\n#6 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/Common/Communication/RetryableServiceClient.php(32): Aliyun\Common\Communication\OpenServiceClient->sendRequest(Object(Aliyun\Common\Communication\HttpRequest), Object(Aliyun\Common\Communication\ExecutionContext))\n#7 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/Common/Communication/RetryableServiceClient.php(27): Aliyun\Common\Communication\RetryableServiceClient->sendRequestImpl(Object(Aliyun\Common\Communication\HttpRequest), Object(Aliyun\Common\Communication\ExecutionContext), 0)\n#8 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/Common/Communication/Command.php(121): Aliyun\Common\Communication\RetryableServiceClient->sendRequest(Object(Aliyun\Common\Communication\HttpRequest), Object(Aliyun\Common\Communication\ExecutionContext))\n#9 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/OSS/OSSClient.php(429): Aliyun\Common\Communication\Command->execute(Array, Array)\n#10 /data/os/chensha/jpos/vendor/johnlui/aliyun-oss/src/oss/src/Aliyun/OSS/OSSClient.php(153): Aliyun\OSS\OSSClient->execute('putObject', Array)\n#11 /data/os/chensha/jpos/library/OSSUpload.php(88): Aliyun\OSS\OSSClient->putObject(Array)\n#12 /data/os/chensha/jpos/modules/webapi/site/controllers/SiteController.php(111): app\library\OSSUpload->upload()\n#13 [internal function]: app\modules\webapi\site\controllers\SiteController->actionUploadImg()\n#14 /data/os/chensha/jpos/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)\n#15 /data/os/chensha/jpos/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)\n#16 /data/os/chensha/jpos/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('upload-img', Array)\n#17 /data/os/chensha/jpos/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('site/site/uploa...', Array)\n#18 /data/os/chensha/jpos/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))\n#19 /data/os/chensha/jpos/web/index-dev.php(12): yii\base\Application->run()\n#20 {main}"
博主你好, 现在项目需要让上传的文件直接在浏览器显示, 由于没有设置 MIME 类型浏览器不认识上传的文件导致直接下载, 您的组件中貌似没有发现设置contentType的方法, 还是说看漏了..请问博主有这个方法吗???
谢谢作者的分享@johnlui
看到demo的privateUpload方法会返回boolean的值,但是打印出来并没有?图片是能够正常上传的。
AliyunOSS这个类里面都是http的,我们使用https的,下载时我们网站发现http的连接多个时有问题,所以想问下oss的能不能提供https的链接
能在AliyunOSS这个类里面加个访问私有Bucket里面文件并生成加密时效链接的方法吗?
请问,大文件的断点续传应该如何处理呢?
@johnlui 计划什么时候发布新版本?
我使用的是Laravel5.2 ,用了您的包以后,使用OSS出现
ClientException in Command.php line 135:
Undefined index: host
这个如何解决?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.