【问题标题】:Pinata cloud Video extraction: The operation is insecure皮纳塔云视频提取:操作不安全
【发布时间】:2022-02-01 04:45:55
【问题描述】:

我正在尝试从 IPFS 云 (pinata.cloud) 中的视频获取缩略图,但我收到错误“操作不安全”。

视频链接:https://gateway.pinata.cloud/ipfs/QmWWeXfCNrgThTzAxbS7AZywnsgp2sdB9rbi5kxuUyUwpZ

到目前为止,我有这个:

<video id="videoHolder" controls>
  <source src="https://gateway.pinata.cloud/ipfs/QmWWeXfCNrgThTzAxbS7AZywnsgp2sdB9rbi5kxuUyUwpZ" type="video/mp4" />
</video>

<canvas id="canvas-element"></canvas>

<a id="test-link"></a>

<script>
      function thumbnails() {
        var _VIDEO = document.querySelector("#videoHolder"),
            _CANVAS = document.querySelector("#canvas-element"),
            _CANVAS_CTX = _CANVAS.getContext("2d");

        _CANVAS_CTX.drawImage(_VIDEO, 0, 0, _VIDEO.videoWidth, _VIDEO.videoHeight);

        // Video metadata is loaded
        _VIDEO.addEventListener('loadedmetadata', function() {
            // Set canvas dimensions same as video dimensions
            _CANVAS.width = _VIDEO_PICTURE.videoWidth;
            _CANVAS.height = _VIDEO_PICTURE.videoHeight;
        });

        download()
    }

    var download = function(){
        var link = document.getElementById('test-link');
        link.download = 'filename.png';
        link.href = document.getElementById('canvas-element').toDataURL()
    }
</script>

我还在某处读到它是 crossOrigin 的一部分,但由于它位于 IPFS 上,因此我无法对其进行编辑(据我所知)。

那么,我怎样才能实现使用 JavaScript 在 IFPS 上从该视频中获取缩略图的目标?

【问题讨论】:

    标签: javascript extract thumbnails ipfs cross-origin-read-blocking


    【解决方案1】:

    这与 ipfs:// 协议无关,因为 Pinata 的云服务通过 https:// 提供该内容。

    这里有一个与操作不安全错误相关的问题:canvas.toDataURL() Security Error The operation is insecure

    这个问题的最佳答案解释了为什么你不能绕过这个安全功能:Why can't I force download of tainted canvas and why is it a security issue?

    使用反向代理作为受信任的来源来提供 IPFS 内容会冒高带宽的风险,因此您可能需要查看使用服务器提取托管在 Pinata 云上的视频帧的路线。

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 1970-01-01
      • 2013-06-06
      • 1970-01-01
      • 2014-11-03
      • 1970-01-01
      • 2018-09-07
      • 2012-11-01
      • 2016-04-26
      相关资源
      最近更新 更多