Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
微软认知API一直在告诉我:“我们的;“讯息”:&引用;输入数据不是有效的图像或受密码保护的数据。”;_Api_Blob - Fatal编程技术网

微软认知API一直在告诉我:“我们的;“讯息”:&引用;输入数据不是有效的图像或受密码保护的数据。”;

微软认知API一直在告诉我:“我们的;“讯息”:&引用;输入数据不是有效的图像或受密码保护的数据。”;,api,blob,Api,Blob,我有一个图像的base64字符串,我正试图将其转换为“应用程序/八位字节流”,因为这是api所需要的。我想我已经创建了一个blob,正如你从我的函数中看到的那样。当我调用api时,我总是在标题中看到消息。有人知道怎么了吗 我想这可能是因为我的blob不是一个八位字节流,但我已经尝试发送普通的base64字符串和blob。请帮帮我,真的很绝望 const blobPdfFromBase64String = base64String => { const byteArray =

我有一个图像的base64字符串,我正试图将其转换为“应用程序/八位字节流”,因为这是api所需要的。我想我已经创建了一个blob,正如你从我的函数中看到的那样。当我调用api时,我总是在标题中看到消息。有人知道怎么了吗

我想这可能是因为我的blob不是一个八位字节流,但我已经尝试发送普通的base64字符串和blob。请帮帮我,真的很绝望

const blobPdfFromBase64String = base64String => {
        const byteArray = base64.toByteArray(base64String);
       return new Blob([byteArray], { type: 'application/octet-stream' });
    };

    let img = route.params.image;


    const sendImage = async() => {
        let url = `${config.ENDPOINT}vision/v3.0/read/analyze`;
        let headers = new Headers();
        let blob = blobPdfFromBase64String(img.base64);
        headers.append('Content-Type', 'application/octet-stream');
        headers.append('Ocp-Apim-Subscription-Key', config.KEY);
        try {
            let response = await fetch(url, { method:'POST', headers, body:blob});
            let json = await response.json();
            console.log(json)
            return json;
        } catch (error) {
            console.log(`Error in sendImage, ${error}`);
        }
    }