Submiting via APIΒΆ

If you are a registered user, you can use the Corvus API to submit samples and collect the results.

Following a sample code:

import requests
import os
import sys
import json
import time

# api key
API_KEY = 'X'
# api url
URL = 'https://corvus.inf.ufpr.br/api/submission/'

# file to be uploaded
file_location = sys.argv[1]

# file to be sent via request
file = {"file_uploaded": (os.path.basename(file_location), open(file_location,'rb')) }

# data to be sent
# id of the group to send samples
# public: just do not send a group_id
data = {"group_id": X}

# request headers
headers = {"Authorization": "Token {}".format(API_KEY)}

# send request
response = requests.post(URL, files=file, data=data, headers=headers)

# get response
res = json.loads(response.text)
try:
    file_md5 = res['md5']
    report = res['report_found']
    while(not report):
        # polling
        time.sleep(30)
        URL = 'https://corvus.inf.ufpr.br/api/get-submission-results/'
        headers = {"Authorization": "Token {}".format(API_KEY)}
        response = requests.post(URL, data={"file_md5": file_md5}, headers=headers)
        res = json.loads(response.text)
        report = res['report_finished']
    open(sys.argv[2],"w").write(response.text)
except:
    sys.exit(0)

Enjoy!