MCPcopy Create free account
hub / github.com/StackStorm/st2 / _include_file

Method _include_file

st2api/st2api/controllers/v1/pack_views.py:152–166  ·  view source on GitHub ↗

Method which returns True if the following file content should be included in the response. Right now we exclude any file with UTF8 BOM character in it - those are most likely binary files such as icon, etc.

(self, file_path, content)

Source from the content-addressed store, hash-verified

150 return result
151
152 def _include_file(self, file_path, content):
153 """
154 Method which returns True if the following file content should be included in the response.
155
156 Right now we exclude any file with UTF8 BOM character in it - those are most likely binary
157 files such as icon, etc.
158 """
159 if codecs.BOM_UTF8 in content[:1024]:
160 return False
161
162 if b"\0" in content[:1024]:
163 # Found null byte, most likely a binary file
164 return False
165
166 return True
167
168
169class FileController(BaseFileController):

Callers 1

get_oneMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected