API Docs Help

Submit File

POST method/v1/nsfw/images/submit/file

Submits a file for asynchronous NSFW image scanning. Supported image file types:

  • JPEG

  • PNG

  • GIF

  • WebP

The result can be obtained later by calling GET /v1/nsfw/images/{id}. Alternatively, if a webhook callback URL is provided, the result will be sent automatically when ready.

Request parameters

# Callback URL is optional curl https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file \ --header 'X-API-Key: YOUR_API_KEY' \ --form file=@/path/to/a/image.jpg \ --form callback_url=https://www.example.com
const axios = require('axios'); const fs = require('fs'); const FormData = require('form-data'); const api = axios.create({ baseURL: 'https://eu1.api.av.ionxsolutions.com/v1/' }); const formData = new FormData(); formData.append('file', fs.createReadStream('/path/to/a/image.jpg'), 'image.jpg'); // Callback URL is optional formData.append('callback_url', 'https://www.example.com'); api.post('malware/submit/file', formData, { headers: { ...formData.getHeaders(), 'X-API-Key': 'YOUR_API_KEY' } }).then(res => { console.log('response', res.data); }).catch(err => { console.log('error', err); });
using var client = new HttpClient(); client.BaseAddress = new Uri("https://eu1.api.av.ionxsolutions.com/v1/"); client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY"); using var file = File.OpenRead("/path/to/a/image.jpg"); using var formData = new MultipartFormDataContent(); formData.Add(new StreamContent(file), "file", file.Name); // Optional callback URL formData.Add(new StringContent("https://www.example.com"), "callback_url"); using var response = await client.PostAsync("malware/submit/file", formData); response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.RequestBody; import okhttp3.Request; import okhttp3.Response; import java.io.File; import java.io.IOException; String apiKey = "YOUR_API_KEY"; String url = "https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file"; String filePath = "/path/to/a/image.jpg"; OkHttpClient client = new OkHttpClient(); File file = new File(filePath); MediaType mediaType = MediaType.parse("image/jpeg"); RequestBody fileBody = RequestBody.create(file, mediaType); // Callback URL is optional RequestBody requestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("file", "image.jpg", fileBody) .addFormDataPart("callback_url", "https://www.example.com") .build(); Request request = new Request.Builder() .url(url) .addHeader("X-API-Key", apiKey) .post(requestBody) .build(); Response response = client.newCall(request).execute(); if (response.isSuccessful()) { System.out.println(response.body().string()); } else { System.err.println("Request failed. Status code: " + response.code()); System.err.println("Response message: " + response.message()); System.err.println(response.body().string()); }
import requests url = 'https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file' headers = { 'X-API-Key': 'YOUR_API_KEY' } files = { 'file': ('image.jpg', open('/path/to/a/image.jpg', 'rb')) } # Callback URL is optional data = { 'callback_url': 'https://www.example.com' } response = requests.post(url, headers=headers, files=files, data=data) print(response.text)
package main import ( "bytes" "fmt" "io" "mime/multipart" "net/http" "os" ) func main() { apiKey := "YOUR_API_KEY" url := "https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file" var buffer bytes.Buffer writer := multipart.NewWriter(&buffer) file, err := os.Open("/path/to/a/image.jpg") if err != nil { fmt.Println(err) return } defer file.Close() fileWriter, _ := writer.CreateFormFile("file", "image.jpg") io.Copy(fileWriter, file) // Callback URL is optional _ = writer.WriteField("callback_url", "https://www.example.com") writer.Close() req, _ := http.NewRequest("POST", url, &buffer) req.Header.Set("Content-Type", writer.FormDataContentType()) req.Header.Set("X-API-Key", apiKey) client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println(err) return } defer resp.Body.Close() if resp.StatusCode == 202 { var respBuffer bytes.Buffer io.Copy(&respBuffer, resp.Body) fmt.Println(respBuffer.String()) } else { fmt.Printf("Request failed. Status code: %d\n", resp.StatusCode) } }
require 'net/http' require 'uri' url = URI.parse('https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file') file_path = '/path/to/a/image.jpg' request = Net::HTTP::Post.new(url) request['X-API-Key'] = 'YOUR_API_KEY' # Callback URL is optional request.set_form([ ['file', File.open(file_path)], ['callback_url', 'https://www.example.com'] ], 'multipart/form-data') response = Net::HTTP.start(url.hostname, url.port, use_ssl: true) do |http| http.request(request) end puts response.body
<?php $url = 'https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file'; $api_key = 'YOUR_API_KEY'; $file_path = '/path/to/a/image.jpg'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Callback URL is optional $form = [ 'file' => new \CurlFile($file_path, 'image/jpeg', 'image.jpg'), 'callback_url' => 'https://www.example.com' ]; curl_setopt($curl, CURLOPT_POSTFIELDS, $form); $headers = array(); $headers[] = 'Content-Type: multipart/form-data'; $headers[] = 'X-API-Key: '.$api_key; curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($curl); if ($result === false) { curl_close($curl); die('Curl error: '.curl_error($curl).'('.curl_errno($curl).')'); } $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($http_code != 202) { die('HTTP error: Status code '.$http_code); } echo $result;
$Uri = "https://eu1.api.av.ionxsolutions.com/v1/nsfw/images/submit/file" $Headers = @{ "X-API-Key" = "YOUR_API_KEY" }; # Callback URL is optional $Form = @{ file = Get-Item -Path "/path/to/a/image.jpg" callback_url = "https://www.example.com" } $Result = Invoke-RestMethod -Uri $Uri -Method Post -Headers $Headers -Form $Form Write-Host ($Result | ConvertTo-Json)

Responses

{ "type": "https://tools.ietf.org/html/rfc9110#section-15.6.1", "title": "Internal Server Error", "status": 500, "detail": "Something went wrong", "traceId": "00-17d017df2498eac9e698f1a06747a161-c9d4f32199479052-01" }
{ "id": "eb0de022-edd2-4ea4-bdd6-29dc9d4d6520" }
{ "type": "https://datatracker.ietf.org/doc/html/rfc7807#section-15.5.21", "title": "One or more validation errors occurred.", "status": 422, "instance": "/v1/nsfw/images/submit/file", "errors": { "file_name": [ "Invalid filename - too long" ] }, "traceId": "00-f4ee9395de696115b3b8af12e193c3d0-3b2749428bed3231-01" }
Last modified: 08 November 2024