[Up]: Storage API : GetChecksum
Script path: /storage/bin/api/get_checksum.cgi
Description: Get the MD5 checksum of a file and optionally request to verify it against a given the MD5 checksum.
INPUT (via GET or POST)
Mandatory parameters are: sid, path
Optional parameters are: checksum, ofmt
sid | session id of the login user. [mandatory] |
path | path to a file [mandatory] Please refer to [How to specify a path]. path must point to an existing file. e.g. |
checksum | =<MD5_checksum> If checksum is not specified, it is taken to mean to just return the MD5 checksum of the file. If checksum is specified, it is taken to mean to verify the file's checksum against it and return a match or unmatch status. MD5_checksum is represented as 32 hex digits in an ascii string of 32 characters (lowercased). MD5 is a 32-bit checksum (fingerprint or message digest) of a file. |
ofmt | = null | json | jsonp null is the default, and the legacy "flat" output format is returned. json means the output format is in JSON format jsonp is like json, but in "pretty" form for easier human readability. |
OUTPUT (content-type: text/plain)
Successful return:
(WHEN REQUESTING for checksum)
true <TAB> <MD5_checksum> <newline>
e.g.
true <TAB> 132987c6ea9a9dfa1e0ccb79eae16af6Equivalent JSON output:
{
"checksum" : "132987c6ea9a9dfa1e0ccb79eae16af6",
"status" : true
}
(WHEN VERIFYING against a given checksum)
true<TAB><Server_MD5_checksum><TAB><match|unmatch><newline>
e.g.
true <TAB> 132987c6ea9a9dfa1e0ccb79eae16af6 <TAB> match
OREquivalent JSON output:
true <TAB> 132987c6ea9a9dfa1e0ccb79eae16af6 <TAB> unmatch
{
"csum_verify" : "unmatch",
"checksum" : "ba45c8f60456a672e003a875e469d0eb",
"status" : true
}
Unsuccessful return:
false<tab><error message><newline>
e.g.
false <TAB> File does not exist.Equivalent JSON output:
{In both legacy "flat" output and also JSON output, appropriate HTTP header status codes are also returned e.g. 200 OK, 401 Invalid user profile, etc.
"http_status" : "404 File does not exist",
"status" : false,
"errmsg" : "File does not exist."
}