MCPcopy Index your code
hub / github.com/modelscope/modelscope / encode_file_to_base64

Function encode_file_to_base64

modelscope/utils/service_utils.py:123–129  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

121
122
123def encode_file_to_base64(f):
124 with open(f, 'rb') as file:
125 encoded_string = base64.b64encode(file.read())
126 base64_str = str(encoded_string, 'utf-8')
127 mimetype = get_mimetype(f)
128 return ('data:' + (mimetype if mimetype is not None else '')
129 + ';base64,' + base64_str)
130
131
132def encode_url_or_file_to_base64(path):

Callers 1

Calls 2

get_mimetypeFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…