This function will check if a file already exists and is attached to particular device/deployment using a file's originalname. It will return a list of files that are NOT yet on the server
Requires data.
device : Required if deployment or device token is not supplied. devicelabel of a device in the database.
deployment : Required if device or device token is not supplied. deploymentdeviceID of a deployment in the database.
originalnames : Required. List of originalnames (including extension) to be checked.
api_url = "https://arisemdsvm.science.uva.nl//api-token-auth/"
response = requests.post(api_url,{"username":username,"password":password})
token=response.json()['token']
#Check a specific deployment
api_url = "http://arisemds.science.uva.nl/api/FileUploadCheck/"
response = requests.post(api_url,
headers={'Authorization': 'token {}'.format(token)},
data={"deployment":"mydeploymentid",
"originalnames"["myfile1.jpg","myfile2.jpg"]
)
print(response.json())
#Check a device
response = requests.post(api_url,
headers={'DeviceToken': devicetoken},
data={"device":"mydevicelabel",
"originalnames"["myfile1.jpg","myfile2.jpg"]
)
print(response.json()
#Check a device using a device token
response = requests.post(api_url,
headers={'Authorization': 'token {}'.format(token)},
data={
"originalnames"["myfile1.jpg","myfile2.jpg"]
)
print(response.json()
URL : api/Fileupload/
Method : PUT
Auth required : YES