class FileUploadTagger

Defined in:

tagger/taggers/file_upload.cr

Constant Summary

MEDIA_UPLOAD_PARAM_TYPES = Set {"file", "form"}

Form-style carriage: a genuine browser file upload arrives as a file param or a multipart form field. JSON/body media fields are almost always a URL/reference string.

MEDIA_WORDS = Set {"image", "images", "photo", "photos", "avatar", "media"}

Media words that frequently name a reference — a profile-image URL, an avatar link — inside a JSON/body payload rather than an uploaded file. Treated as an upload only when carried as multipart form data (a file/form param) or corroborated by an upload-ish URL, so a JSON {"image": "https://..."} field (e.g. RealWorld's PUT /user) is not mis-tagged as a file upload.

SEGMENT_ONLY_PATH_PARTS = Set {"media"}

media is matched only as a whole /media path segment, never as a loose sub-token. As a loose token (split on -/_) it fired on config/feature routes that merely contain the word but upload nothing: /settings/media-path (a media-directory setting, e.g. koel), /social-media, /media-library. A standalone /media collection (POST /media) still tags.

UPLOAD_METHODS = Set {"POST", "PUT", "PATCH"}
UPLOAD_PARAM_TYPES = Set {"file", "form", "body", "json"}
UPLOAD_PATH_PARTS = Set {"upload", "uploads", "attach", "attachment", "attachments", "import", "imports", "avatar", "photo", "photos", "file", "files", "image", "images", "picture", "pictures"}
WORDS = Set {"file", "files", "upload", "attachment", "attachments", "document", "documents", "multipart", "content_type", "filename", "content_disposition"}

Param names that denote an actual uploaded file regardless of how the value is carried — a filename, an attachment, a multipart boundary. Safe to flag on any writable param type.

Constructors

Instance Method Summary

Instance methods inherited from class Tagger

name : String name, perform(endpoints : Array(Endpoint)) : Array(Endpoint) perform

Constructor methods inherited from class Tagger

new(options : Hash(String, YAML::Any)) new

Constructor Detail

def self.new(options : Hash(String, YAML::Any)) #

[View source]

Instance Method Detail

def perform(endpoints : Array(Endpoint)) #

[View source]