2017-10-11 41 views
1

我使用的是HTML5下載屬性,允許用戶從S3下載的視頻文件:什麼S3 cors配置應該用於Firefox html5下載屬性?

<a href="https://mybucket.s3.amazonaws.com/video.mp4" download="video.mp4">Download</a> 

這工作完全在Chrome和IE瀏覽器。從下面的問題,據我所知,Firefox的希望CORS啓用,允許下載屬性進行跨領域產地:

HTML5 download attribute not working when downloading from another server, even when Access-Control-Allow-Origin is set to all (*)

我已經使用以下方法使我的S3存儲CORS:

http://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-cors-configuration.html

這是我CORS政策:

<CORSConfiguration> 
    <CORSRule> 
     <AllowedOrigin>*</AllowedOrigin> 
     <AllowedMethod>GET</AllowedMethod> 
     <MaxAgeSeconds>3000</MaxAgeSeconds> 
     <AllowedHeader>Authorization</AllowedHeader> 
    </CORSRule> 
</CORSConfiguration> 

火狐仍然沒有不想下載視頻。任何幫助,提示或建議將不勝感激。謝謝。

+0

你得到了什麼錯誤?請分享一個屏幕截圖或複製並粘貼這些錯誤。 – Kannaiyan

+0

當我點擊使用Firefox的下載鏈接時,mp4視頻在新標籤中打開而不是下載。 – boblapointe

回答

0

您的CORS策略需要授權標題。將其更改爲通配符。

在AllowedHeader變化<AllowedHeader>*</AllowedHeader>

0

有幾個你需要做的檢查,

確保內容類型是application/octet-stream。默認情況下,它是一樣的,除非你改變它。

火狐處理MP4文件不同,

1. Enter about:config in the address bar 
2. Hit Enter 
3. Click I’ll be careful, promise! 
4. In the Search field, enter media.windows-media-foundation.enabled 
5. Double-click the True in the media.windows-media-foundation.enabled result to change it to False 
6. Close the browser tab 

然後Firefox將自動下載該文件。

參考:

https://jdrch.wordpress.com/2013/10/01/how-to-prevent-firefox-from-playing-direct-link-mp4-files-in-the-browser/

希望它能幫助。

+0

謝謝你的幫助。但要求所有用戶更改他們的Firefox配置不是一種選擇。 – boblapointe

相關問題