如何使用JavaScript查找MIME类型的IPF(未给出的扩展名)?
如果我有一个IPFS CID地址(没有扩展),则 这样的文件为实例https://ipfs.infura.io/ipfs/qmnhq4hx1kftw1a5ptttudgxm9q4xhwdeuwtpssg19sssseu
,我如何找到使用Javascript的Mime类型?
我已经尝试了以下操作:
let file='https://ipfs.infura.io/ipfs/QmNhq4hx1KfTw1a5pTtudGXm9Q4xhWdeuWtPSSG19SSZeU'
if (window.FileReader && window.Blob) {
console.log("All the File APIs are supported by the browser.");
console.log("Type: " + file.type);
} else {
console.log("File and Blob are not supported by the browser");
}
这总是给我未定义的
。 任何帮助都将不胜感激。
If I have an IPFS CID address (with no extension), of a
file like this for instance https://ipfs.infura.io/ipfs/QmNhq4hx1KfTw1a5pTtudGXm9Q4xhWdeuWtPSSG19SSZeU
, how can I find its MIME type using Javascript?
I've tried the following:
let file='https://ipfs.infura.io/ipfs/QmNhq4hx1KfTw1a5pTtudGXm9Q4xhWdeuWtPSSG19SSZeU'
if (window.FileReader && window.Blob) {
console.log("All the File APIs are supported by the browser.");
console.log("Type: " + file.type);
} else {
console.log("File and Blob are not supported by the browser");
}
This is always giving me undefined
.
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一个URL,因此要获得MIME类型,您可以提出HTTP Head请求。
You have a url, so to get the mime type you can make a HTTP HEAD request.