Giter Site home page Giter Site logo

aliyunoss's Issues

功能添加

封装后对阿里云缺少了不少功能,例如Object的删除,以及大文件的分块上传等。
这几个功能用的还是比较多的。建议AliyunOSS.php类里面添加新的函数。

oss dispatch错误

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}"

建议$oss = new OSS();改下成new self().这样就可以随便更改类名。

/**

  • 使用外网上传文件
  • @param string bucket名称
  • @param string 上传之后的 OSS object 名称
  • @param string 删除文件路径
  • @return boolean 上传是否成功
    */
    public static function publicUpload($bucketName, $ossKey, $filePath, $options = [])
    {
    $oss = new OSS();
    $oss->ossClient->setBucket($bucketName);
    return $oss->ossClient->uploadFile($ossKey, $filePath, $options);
    }

/**
* 使用外网上传文件
* @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);
}

存储文件过期

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

组件设置 文件 显示类型

博主你好, 现在项目需要让上传的文件直接在浏览器显示, 由于没有设置 MIME 类型浏览器不认识上传的文件导致直接下载, 您的组件中貌似没有发现设置contentType的方法, 还是说看漏了..请问博主有这个方法吗???

建议新增getUrl方法

RuntimeException in FilesystemAdapter.php line 322: This driver does not support retrieving URLs.

The specified bucket is not valid.

输入正确的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 publicUploadContent($bucketName, $ossKey, $content, $options = [])
    {
    $oss = new OSS();
    $oss->ossClient->setBucket($bucketName);
    return $oss->ossClient->uploadContent($osskey, $content, $options);//这里哦,$ossKey
    }

/**

  • 使用阿里云内网直接上传变量内容
  • @param string bucket名称
  • @param string 上传之后的 OSS object 名称
  • @param string 删除传的变量
  • @return boolean 上传是否成功
    */
    public static function privateUploadContent($bucketName, $ossKey, $content, $options = [])
    {
    $oss = new OSS(true);
    $oss->ossClient->setBucket($bucketName);
    return $oss->ossClient->uploadContent($osskey, $content, $options);
    }

Undefined index: host

我使用的是Laravel5.2 ,用了您的包以后,使用OSS出现

ClientException in Command.php line 135:
Undefined index: host

这个如何解决?

文件没有正确关闭的bug

在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;

}

laravel 7 不适配

Argument 1 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an object, string given,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.