如何通過 Storage Facade(在 Laravel 5 中)獲取下載文件的進度條? (How to get a progress bar for downloading a file via Storage Facade (in Laravel 5)?)


問題描述

如何通過 Storage Facade(在 Laravel 5 中)獲取下載文件的進度條? (How to get a progress bar for downloading a file via Storage Facade (in Laravel 5)?)

您好,這是我用於使用 Laravel5 和 Storage Facade 為虛擬磁盤下載文件的代碼(非常簡單):

//implemented as a Artisan Console command
$contents = Storage::disk('remoteDisk')‑>get($filePath);
Storage::disk('csv')‑>put($filePathTarget, $contents); 

我希望在輸出中看到一個進度條,如文檔建議:

$bar = $this‑>output‑>createProgressBar($count);
//do something
$bar‑>advance();
//i'm done
$bar‑>finish();

既然Storage方法get()不是循環,那如何“推進”進度條呢?

初始化可以是:

  $size_remote = Storage::disk('remoteDisk')‑>size($filePath);
  $size = Storage::disk('csv')‑>size($filePath);

但是如何/在哪裡獲取臨時文件文件大小以在下載期間推進進度條?


參考解法

方法 1:

It's doable, but you are going to need JavaScript.

Also it's been answered already on StackOverflow here.

(by koalaokAlex)

參考文件

  1. How to get a progress bar for downloading a file via Storage Facade (in Laravel 5)? (CC BY‑SA 2.5/3.0/4.0)

#Laravel #progress-bar #storage #download






相關問題

Laravel Put Route Giving 404 錯誤 (Laravel Put Route Giving 404 Error)

顯示數組中的類別和子類別 (Display categories and subcategories from an array)

在 Laravel 中合併表單請求 (Combining Form Requests in Laravel)

Laravel - 加載 2 個模型之間的樞軸信息 (Laravel – load pivot information between 2 models)

如何將請求從流明中的一個動作重定向到另一個動作 (How do I redirect request to another action from one action in Lumen)

構建 JavaScript 時缺少模塊 (Missing Module When Building JavaScript)

將數據行轉換為 1 個對象 (Convert data rows to 1 object)

多對多關係同步刪除所有選定的選項 (Many to many relationship Sync removes all selected options)

Eloquent 的可填充不能與 mutators 一起使用 (Eloquent's fillable not working with mutators)

代幣支付 Laravel (Coinpayment Laravel)

API 憑證應該存儲在 laravel 中的哪個位置? (Where API credentials should be stored in laravel?)

Laravel Eloquent 使用嵌套關係構建 eloquent 集合 (Laravel Eloquent use nested relationship to construct eloquent collection)







留言討論