3
我使用the PHP Flysystem包處理來自我的AWS S3存儲桶的內容。特別是,我正在使用$filesystem->readStream
。如何將文件流式傳輸到AWS S3中的一個Zip中
我的問題
當我流的文件,它在myzip.zip結束和大小是正確的,但如果將它解壓縮,它成爲myzip.zip.cpgz。這是我的原型:
header('Pragma: no-cache');
header('Content-Description: File Download');
header('Content-disposition: attachment; filename="myZip.zip"');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
$s3 = Storage::disk('s3'); // Laravel Syntax
echo $s3->readStream('directory/file.jpg');
我在做什麼錯?
邊問
當我流的文件這樣的,做的:
- 得到完全下載到我的服務器的內存,然後得到轉移到客戶端,或
- 做它在緩衝區中保存 - 分塊 - 然後傳送到客戶端?
基本上被負擔我的服務器,如果我有有幾十個GB的數據被傳輸的內容?
什麼是tmpfile()在這種情況下?這應該是獲取臨時文件的路徑嗎? –
@ mark.inman PHP的[tmpfile()](http://php.net/manual/en/function.tmpfile.php)函數 「以讀寫(w +)模式創建具有唯一名稱的臨時文件,並且返回一個文件句柄。「 要獲取臨時文件的路徑,請執行[stream_get_meta_data()](http://php.net/manual/en/function.stream-get-meta-data.php)函數並訪問其返回值的' uri'用'$ zipPath'和'$ jpgPath'顯示 – bradynpoulsen