[英]Use a Firebase storage URL with moderatecontent API
I'd like to be able to check, via an API, if an image uploaded to Firebase storage is NSFW.我希望能够通过 API 检查上传到 Firebase 存储的图像是否为 NSFW。
I want to do it with moderatecontent.com and this is what I tried我想用 moderatecontent.com 来做,这就是我试过的
axios.get('https://api.moderatecontent.com/moderate/', {
params: {
key: '50f4e0ecf62fdef40abf30a102c8d055',
url: img,
},
})
The issue I have is that the Firebase URL comes with a token like so我遇到的问题是 Firebase URL 带有这样的令牌
https://firebasestorage.googleapis.com/v0/b/something.appspot.com/o/imagename?alt=media&token=SOMETOKEN
the problem is that the token ends up being used as a param in the request.问题是令牌最终被用作请求中的参数。 My Firebase Storage rules are
我的 Firebase 存储规则是
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if true;
allow write: if request.auth != null;
}
}
}
Do you have any idea how to make moderatecontent api access the url directly?你知道如何让 moderatecontent api 直接访问 url 吗?
Full disclosure: I work for moderatecontent.com全面披露:我为 moderatecontent.com 工作
A GET request with a URL that includes a query string, often will not work, due to the image query string interfering with the GET query string.由于图像查询字符串干扰 GET 查询字符串,因此包含查询字符串的 URL 的 GET 请求通常不起作用。
https://firebasestorage.googleapis.com/v0/b/something.appspot.com/o/imagename?alt=media&token=SOMETOKEN
https://api.moderatecontent.com/moderate/?url=https://firebasestorage.googleapis.com/v0/b/something.appspot.com/o/imagename?alt=media&token=SOMETOKEN&key=12344df5dfad1234e05fd617dee81234
The moderatecontent.com API includes support for a POST request (as well as base64), and these two options allow for an image URL with a query string. moderatecontent.com API 包括对 POST 请求(以及 base64)的支持,这两个选项允许带有查询字符串的图像 URL。
For example:例如:
var axios = require('axios');
var qs = require('qs');
var data = qs.stringify({
'url': 'https://www.moderatecontent.com/img/sample_face_6.jpg',
'key': '12344df5dfad1234e05fd617dee81234'
});
var config = {
method: 'post',
url: 'https://api.moderatecontent.com/moderate/',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.