Javascript 如何将文件路径URI转换为可读的https URL
是否有一种方法可以将捕获的文件路径uri转换为这样的uriJavascript 如何将文件路径URI转换为可读的https URL,javascript,azure,https,filepath,Javascript,Azure,Https,Filepath,是否有一种方法可以将捕获的文件路径uri转换为这样的uri file:///var/mobile/Containers/Data/Application/1E1E919E-6C21-4CC7-B9C2-5B4B3BC84B0F/Library/Caches/ExponentExperienceData/%2540chuks93%252Fihu-main/Camera/F3B8EBCC-BB09-4603-AF7E-FD3CA792C237.jpg要说一个临时的https URL吗? 我正在使用M
file:///var/mobile/Containers/Data/Application/1E1E919E-6C21-4CC7-B9C2-5B4B3BC84B0F/Library/Caches/ExponentExperienceData/%2540chuks93%252Fihu-main/Camera/F3B8EBCC-BB09-4603-AF7E-FD3CA792C237.jpg
要说一个临时的https URL吗?
我正在使用Microsoft azure face API,我遇到了一些错误,这些错误表明运行API的唯一方法是使用网络URL,如https
有人知道这方面的解决方案吗
export default {
processImage: (image) => {
// Replace the subscriptionKey string value with your valid subscription key.
var subscriptionKey = "********************";
var uriBase = "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise";
// Display the image.
var sourceImageUrl = image;
console.log(typeof sourceImageUrl)
console.log("here", sourceImageUrl);
// Perform the REST API call.
return fetch(uriBase, {
method: 'POST',
headers: {
"Content-type": "application/json",
"Ocp-Apim-Subscription-Key": subscriptionKey
},
body: JSON.stringify({ uri: sourceImageUrl })
})
.then((data) => data.json())
.then(function (data){
console.log("hello", data);
})
.catch(function (error) {
console.log(error);
});
}
}我相信你弄错了。您需要通过HTTPS调用Face API,并在POST请求中将图像blob上载为。那么,有没有办法使用react native camera拍摄的照片并将其传递到API中,这样就可以了?也许正如你所说的,通过HTTPS调用它?是的,当然,这只是一个POST请求-请参见上文,我添加了我的代码。当我使用react本机相机拍照时,它返回一个文件uri“file://”,但API似乎只对以“https://”开头的文件起作用。