実現したいこと
サーバ上にあるmp4ファイルの動画を"example.mp4"としてiPhone上にダウンロードしたいです。
発生している問題
iPhone版Chromeで、ダウンロードした際に「document」という名前でダウンロードされてしまいます。
環境
- iOS: 14.1
- chromeのバージョン:86.0.4240.93
ソースコード
ファイルをダウンロードするため、FileServer.jsを使用しています。
html
1<!doctype html> 2<html lang="ja"> 3 4<head> 5 <meta charset="utf-8"> 6 <title>Download Sample</title> 7 <script src="js/FileSaver.js"></script> 8 <script type="text/javascript"> 9 const contents_url = "a.mp4"; 10 const file_reader = new FileReader(); 11 var out; 12 13 file_reader.onload = function (e) { 14 saveAs(e.target.result, "example.mp4"); 15 } 16 17 function handleDownload() { 18 out = new Blob([contents_url], { type: 'video/mp4' }); 19 file_reader.readAsDataURL(out); 20 } 21 </script> 22</head> 23 24<body> 25 <a href="#" onclick="handleDownload()">ダウンロード</a> 26</body> 27 28</html>
試したこと
PC、Android、iPhone版safariにて試しましたが、全て"example.mp4"でダウンロードできます。
あなたの回答
tips
プレビュー