[英]How do remove unwanted linefeed charachter from file-download in Laravel Nova?
在 Laravel Nova 應用程序中,我遇到了一個奇怪的問題:每當我嘗試下載文件時,我在第一行(0A,一個空行)上有一個換行符。 這會損壞圖像、zip 文件等。 但這是什么原因造成的?
我已經嘗試/檢查過:
這是一些產生此錯誤的 Laravel Nova 代碼:
return Fields\Image::make(__('Image')), 'imageStorage')
->rules('image', "dimensions:max_width={$image_max_width},max_height={$image_max_height}")
->squared()
->disk(Enums\StorageDisk::APP_PUBLIC_DISTRIBUTORS)
->path(DistributorPath::products($distributorId))
->deletable(false)
->prunable()
->onlyOnForms();
第一個字符始終為 0A。
那么,我該如何找到原因呢? 有什么技巧或策略嗎?
簡短的回答:換行符隱藏在路由文件中。
這個錯誤幾乎是一年前犯的,直到現在才出現,因為在應用程序創建的任何 output (html / xml) 中都沒有問題。 當我嘗試 output 二進制文件(zip / images)時開始出現問題。
那么我是如何找到這個錯誤的呢? die('find bug;');
對於未來的任何人:
die('find bug;');
在一個地方並進行測試。die('find bug;');
並將其放在下一次通話中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.