使用Flysystem处理大型文件

电脑杂谈  发布时间:2020-03-14 18:00:50  来源:网络整理

手机能fly文件_fly文件手机打开_fly文件怎么播放

使用Flysystem处理大型文件

I'm using Flysystem in a Symfony app to manage files upload / download on S3.

fly文件手机打开_fly文件怎么播放_手机能fly文件

$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).

fly文件怎么播放_手机能fly文件_fly文件手机打开

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 ?

手机能fly文件_fly文件手机打开_fly文件怎么播放

Any suggestions ?

Thanks :)

fly文件怎么播放_fly文件手机打开_手机能fly文件

展开翻译

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

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...