柏树斑点给出错误,无法执行ATOB'在窗口上,带有MKV文件

发布于 2025-02-07 20:46:32 字数 464 浏览 2 评论 0原文

我需要在请求中使用MKV文件测试API。

我对此使用以下代码:

        cy.fixture('video.mkv').then(file => {
            const blob = Cypress.Blob.base64StringToBlob(file, "video/x-matroska")
            cy.request({
                method: ...
                url: ...
                body: blob,
            })

        });

最后,我有一个错误:

“ InvalidCharacterError 要解码的字符串包含Latin1范围之外的字符

无法在“窗口”上执行“ ATOB” : 柏树V10.0.0 你能帮我吗?

I need to test API, with a MKV file in the request.

I use the following code for that:

        cy.fixture('video.mkv').then(file => {
            const blob = Cypress.Blob.base64StringToBlob(file, "video/x-matroska")
            cy.request({
                method: ...
                url: ...
                body: blob,
            })

        });

Finally, I have this error:

"InvalidCharacterError
Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range."

I'm not sure that, for MKV file, I should convert base64 strings to Blob objects.

FYI: I test with Cypress v10.0.0
Can you help me, please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人间☆小暴躁 2025-02-14 20:46:32

我认为您正在寻找arrayBufferToblob

cy.fixture('video.mkv').then(file => {
  const blob = Cypress.Blob.arrayBufferToBlob(file, "video/x-matroska")
  cy.request({...
})

这些是可用的arrayBufferToblob看起来可能(至少没有错误)。

如果在此上没有进行的其他方法,请尝试其他方法。

I think you are looking for arrayBufferToBlob

cy.fixture('video.mkv').then(file => {
  const blob = Cypress.Blob.arrayBufferToBlob(file, "video/x-matroska")
  cy.request({...
})

These are the available Blob functions, and arrayBufferToBlob looks likely (at least, no errors).

Try out other methods if no-go on this one.

维持三分热 2025-02-14 20:46:32

实际上,使用MKV文件,看来我不需要转换为blob对象,因为该文件已通过此文件发送了很好的发送:

    cy.fixture('video.mkv').then(file => {
        cy.request({
            method: ...
            url: ...
            body: **file**,
        })

    });

但是,在请求后,视频始终会损坏。
以下是用于比较的文件内容:

原始内容:

输出内容:

我们可以看到一个零件是修改的,例如一开始,'a3',取而代之的是'ef bf bd'

请注意,此服务效果很好,Ouside cypress,我们能够检索输出视频。

In fact, with a MKV file, it appears that I don't need to convert to blob object, as the request is well sent with this file:

    cy.fixture('video.mkv').then(file => {
        cy.request({
            method: ...
            url: ...
            body: **file**,
        })

    });

However, the video is always damaged after the request.
Here are file content for comparison, before and after:

Original content:
enter image description here

Output content:
enter image description here

We can see that a part was modified, like 'A3' at the beginning, replaced by 'EF BF BD'

Note that this service works fine, ouside Cypress, and we are able to retrieve output video.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文