overtrue/flysystem-qiniu

上传大文件失败

rootrl opened this issue · 3 comments

使用的是writeStream方法。

看源码QiniuAdapter.php,writeStream也不是真正意义上作为stream处理的呀:

这里也是不断读内容,然后最终给$contents这个变量,到时候$contents也是实际上的文件大小了,所以这样写节省不了内存。见源码:

` public function writeStream($path, $resource, Config $config)
{
$contents = '';

    while (!feof($resource)) {
        $contents .= fread($resource, 1024);
    }

    $response = $this->write($path, $contents, $config);

    if (false === $response) {
        return $response;
    }

    return compact('path');

`
还有在write方法中,屏蔽了$error,只返回false,这样不便于我们查问题,最终我是断点打印这个$error才知道报的错误是:“invalid multipart format: multipart: message too large”

上传这块是我思路错了,大文件不该走sdk上传,七牛官方提供了个qshell工具,现在放在后端队列调脚本上传。

嗯,这里 writestram 是指有时候别人从一些资源作为文件上传,而不是从文件

�有大文件上传的可以参考这个:https://segmentfault.com/a/1190000018810399?_ea=9539340