johnlui / AliyunOSS

阿里云 OSS 官方 SDK 的 Composer 封装,支持任何 PHP 项目,包括 Laravel、Symfony、TinyLara 等等。
489 stars 187 forks source link

文件没有正确关闭的bug #3

Closed shoaly closed 9 years ago

shoaly commented 9 years ago

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

}

johnlui commented 9 years ago

:+1:

johnlui commented 9 years ago

Done!