Download file from url that doesn't end with .

2019-09-20 05:14发布

I've seen examples on how to download files programmatically, but they all use direct links, ending with .txt .mp3 .jpg, whatever. However, the link to the file I want to download isn't a direct link: it doesn't end with .extension. How can you download the file in this case?

2条回答
相关推荐>>
2楼-- · 2019-09-20 05:49

When downloading over HTTP, the file name is usually set by the server in Content-Disposition header. If that is not present, it is up to the client to choose the file name (based on the URL or some other strategy). The extension can often be derived from the Content-Type response header. See this for some of standard content types http://en.wikipedia.org/wiki/Internet_media_type

查看更多
beautiful°
3楼-- · 2019-09-20 06:02

Very stupid answer: You can just download it as all other files. Download it the same way as you do with urls with extensions.

查看更多
登录 后发表回答