文件没有正确关闭的bug
Closed this issue · 2 comments
shoaly commented
在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
👍
johnlui commented
Done!