Scripted Uploads

Uploading of images can be scripted for those users that have requirements that do not allow them to upload images manually. For access to this interface a username and password must be requested.

Example command:
curl -u "myusername:mypassword" -F 'fileToUpload=@./126438386X.tiff' https://coversadmin-prod.mhedu.com/supload.php

The command should return one line of JSON. An example of a successful transfer:

{"status":"success","status_message":"image file is valid. uploaded successfully. archived successfully. recorded successfully"}

Checking for a status of "success" is the primary method of verifying the upload completed properly.

Tips for using Curl:
Adding the "-f" option to curl will return a non-zero exit code when an upload fails. "400" errors are returned when an upload fails (invalid ISBN, invalid file, etc.) so those errors can be detected easily without the need to parse the JSON response:

curl -f -u "myusername:badpassword" -F 'fileToUpload=@./126438386X.tiff' https://coversadmin-prod.mhedu.com/supload.php

Curl's exit code for a failed request is "22" for 400-level errors; see the curl documentation for a complete list of exit codes.

An alternate method of checking the result of the upload is by checking the HTTP status code; curl will provide the HTTP status code for you with the "-w" flag:

curl -w '\n%{http_code}\n' -u "myusername:mypassword" -F 'fileToUpload=@./126438386X.tiff' https://coversadmin-prod.mhedu.com/supload.php

This will result in the status code as the second line of output:

{"status":"success","status_message":"image file is valid. uploaded successfully. archived successfully. recorded successfully"}
200