I'd like to be able to check, via an API, if an image uploaded to Firebase storage is NSFW.
I want to do it with moderatecontent.com and this is what I tried
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
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
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?
Full disclosure: I work for 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.
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.
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);
});