Skip to main content

Detect MIME Type

Detects the MIME type of a file or data payload using the ZXing library. Accepts either a file upload or raw data (text or hex-encoded).

Request

POST /nxt?requestType=detectMimeType&data=<data>&filename=<name>&isText=<boolean>

Parameters

NameTypeRequiredDescription
filemultipartConditionalFile upload. Either file or data must be provided.
datastringConditionalRaw data payload. Either file or data must be provided.
filenamestringNoFilename hint for MIME detection.
isTextbooleanNoIf true (default), data is treated as UTF-8 text. If false, data is treated as hex-encoded bytes.

Response

{
"type": "image/jpeg"
}

Response Fields

FieldTypeDescription
typestringDetected MIME type (e.g., image/jpeg, text/plain, application/octet-stream).

Error Responses

ConditionResponse
Missing file or dataJSONResponses.INCORRECT_FILE

Notes

  • This endpoint does not require the blockchain to be running (requireBlockchain = false).
  • Not chain-specific.
  • Does not require admin password authentication (requirePassword = false).
  • Uses Search.detectMimeType() for detection.

Source: DetectMimeType.java.

Example

curl -X POST "http://localhost:22024/nxt" \
-d "requestType=detectMimeType" \
-d "data=Hello World"