
使用Flysystem处理大型文件
I'm using Flysystem in a Symfony app to manage files upload / download on S3.

$downloadableFileStream = $this->get("filesystem")->readStream($document->getDocument()),
$mimeType = $this->get("filesystem")->getMimetype($document->getDocument()),
$filename =$document->getDocument()
if (ob_get_level()) ob_end_clean();
return new StreamedResponse(function () use ($downloadableFileStream, $mimeType, $filename) {
fpassthru($downloadableFileStream);
}, 200, [
'Content-Transfer-Encoding', 'binary',
'Content-Type' => "application/octet-stream",
'Content-Disposition' => ('attachment; filename="' . $filename . '"'),
'Content-Length' => fstat($downloadableFileStream)['size'],
]);
It's really slow for large files,i was thinking using stream does not put all file in memory手机能fly文件, maybe i'm doing something wrong ? (i have the same problem with upload,i'm using putStream).

The download is instant for small files手机能fly文件, but for large files, it seems the complete file is loaded in the filesystem before launch download.
Is there any way to "start" the download not get the entiere file ?

Any suggestions ?
Thanks :)

展开翻译
我在Symfony应用程序中使用Flysystem来管理S3上的文件上传/下载。</ p>
$ downloadableFileStream = $ this-&gt; get(“filesystem”) - &gt; readStream($ document-&gt; getDocument()),
$ mimeType = $ this-&gt; get(“ filesystem“) - &gt; getMimetype($ document-&gt; getDocument()),
$ filename = $ document-&gt; getDocument()
if(ob_get_level())ob_end_clean();
return new StreamedResponse(function ()使用($ downloadableFileStream,$ mimeType,$ filename){
fpassthru($ downloadableFileStream);
},200,[
'Content-Transfer-Encoding','binary',
'Content-Type' =&gt;“application / octet-stream”,
'Content-Disposition'=&gt;('attachment; filename =“'。$ filename。'”'),
'Content-Length'=&gt; fstat( $ downloadableFileStream)['size'],
]);
</ code> </ pre>
对于大文件来说真的很慢,我以为使用流不会将所有文件都放在内存中 ,也许我做错了什么? (我有相同的上传问题,我正在使用putStream)。</ p>
下载是即时的小文件,但对于大文件,似乎完整的文件加载在文件系统中 在发布下载之前。</ p>
有没有办法“开始”下载而不是获取entiere文件?</ p>
有任何建议吗?</ p> \ n
谢谢:)</ p>
</ div>
symfonyphp
||收藏||
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/bofangqi/article-144150-1.html
哈哈
都是高手啊