Silk browser of Kindle has a download bug?

122 Views Asked by At

Suppose that I want to write a web page with laravel5 (a PHP framework) to download a mobi/awz3 file from the Kindle's web browser directly. The code looks like (please refer to the link given above for the detail):

return response()->download(storage_path().'/kindle/'.urldecode($filename).$ext, $fileoutput);

The first parameter is the fullpath of the file. The second parameter is filename.

I face the following problem:

While I can download it from my computer with correct filename setting by $fileoutput, the filename always losses when I download from Kindle's default browser silk. I have check the response header, which is:

Accept-Ranges: bytes
Cache-Control: public
Connection: keep-alive
Content-Disposition: attachment; filename=".azw3"; filename*=utf-8''%E6%B5%AE%E7%94%9F%E5%85%AD%E8%AE%B0.azw3
Content-Length: 1526943
Content-Type: application/octet-stream
Date: Fri, 26 Aug 2016 14:22:06 GMT
Last-Modified: Sat, 28 May 2016 05:55:45 GMT
Server: nginx/1.6.2
Set-Cookie: XSRF-TOKEN=eyJpdiI6IjNBSmV6Q0R6QU8wWTlhSHU2TlFtYmc9PSIsInZhbHVlIjoiYnBGSThcL1wvaFRCSXNUUnIwZjVyR2M3anhMOUFBUDhTeU9zRGI4ODJzbEVCZ3FQMnF6XC81MFBITXJFY0xQQ0s2MytLdGQ5ZGVsUTNPMGdDb09xbXdmNXc9PSIsIm1hYyI6ImUyNTU1YjdjOTMxNDE1NTk1MDg1ZTFiODVhYTYxNTIzZTc0MDg3MzQyNjg0YzQ0MjlkYjllYjYyNTNhNDMwMmUifQ%3D%3D; expires=Fri, 26-Aug-2016 16:22:06 GMT; Max-Age=7200; path=/
laravel_session=eyJpdiI6IlVNY1h4MmVSOGZaS3A2bHRSZkJMWGc9PSIsInZhbHVlIjoiRWtBK01jeHBPZnhEdlVQckh1VkhwTmlNYTBQSHlLUWd6aEY1dmpaMUIzVzNGa1Q2cnZIY1FUcUl3REtLTUdwSTE2OHRXZldDSEVPT2VIZVUzV2JUVkE9PSIsIm1hYyI6IjE5OGQ5MDVhZGMzYzJjZWRjMmNjY2FlYTQxNjc0ZTU4YjkyZTFmYzk2Yjg3YmIwZGNkYWQxMjA0M2UwZTIwYTMifQ%3D%3D; expires=Fri, 26-Aug-2016 16:22:06 GMT; Max-Age=7200; path=/; httponly
strict-transport-security: max-age=15768000

Compared with the one (download an ebook from amazon.com):

Accept-Ranges: bytes
Content-Disposition: attachment; filename=-.azw3; filename*=UTF-8''%e4%b8%89%e5%9b%bd%e6%bc%94%e4%b9%89%20%28%e5%8f%a4%e5%85%b8%e5%90%8d%e8%91%97%e6%99%ae%e5%8f%8a%e6%96%87%e5%ba%93%29.azw3
Content-Length: 1086746
Content-Type: application/x-mobi8-ebook
Date: Fri, 26 Aug 2016 14:55:50 GMT
Etag: "atv:kin:2:7em8xElPVsRobIXa1NiUa2s2zfXgvBRZ8wJeuKk3OeNpRWnSDSkae0GhbcBTm6GbPZdDY/1CbRICldAJKv4gtiK8SMCbGLLWYrJkKurs0VVe3SB6fEgXLtuEirb2OPJMbvVftnTgCXLEEeGe128ba53v7vM/ABoIgQrWCBD7zXs=:vuRb/GOXZICuuca026R6sJpOCdE=:7l7eh3kzFhCeES7yH/6BYA=="
Hint-Sidecar-Download: 0
ResumableDownloadToken: atv:kin:2:7em8xElPVsRobIXa1NiUa2s2zfXgvBRZ8wJeuKk3OeNpRWnSDSkae0GhbcBTm6GbPZdDY/1CbRICldAJKv4gtiK8SMCbGLLWYrJkKurs0VVe3SB6fEgXLtuEirb2OPJMbvVftnTgCXLEEeGe128ba53v7vM/ABoIgQrWCBD7zXs=:vuRb/GOXZICuuca026R6sJpOCdE=:7l7eh3kzFhCeES7yH/6BYA==
Server: Amazon Web Server
x-adp-host: H2KOCVSR4J4L1J

I guess that the silk browser only reads the first filename=".azw3" and can't get the filename from the latter one filename*=utf8....

Any idea to fix this?

UPDATE

After a second search, I find the problem only occurs when the filename is chinese, that is, when $fileoutput is pure english, then the first filename in header is correct.

0

There are 0 best solutions below