MCPcopy
hub / github.com/1Panel-dev/MaxKB / upload

Method upload

apps/oss/serializers/file.py:79–94  ·  view source on GitHub ↗
(self, with_valid=True)

Source from the content-addressed store, hash-verified

77 )
78
79 def upload(self, with_valid=True):
80 if with_valid:
81 self.is_valid(raise_exception=True)
82 meta = self.data.get('meta', None)
83 if not meta:
84 meta = {'debug': True}
85 file_id = meta.get('file_id', uuid.uuid7())
86 file = File(
87 id=file_id,
88 file_name=self.data.get('file').name,
89 meta=meta,
90 source_id=self.data.get('source_id') or FileSourceType.TEMPORARY_120_MINUTE.value,
91 source_type=self.data.get('source_type') or FileSourceType.TEMPORARY_120_MINUTE
92 )
93 file.save(self.data.get('file').read())
94 return f'./oss/file/{file_id}'
95
96 class Operate(serializers.Serializer):
97 id = serializers.UUIDField(required=True)

Callers 15

postMethod · 0.45
postMethod · 0.45
upload_knowledge_fileMethod · 0.45
upload_tool_fileMethod · 0.45
upload_knowledge_fileMethod · 0.45
upload_tool_fileMethod · 0.45
upload_knowledge_fileMethod · 0.45
upload_tool_fileMethod · 0.45
upload_knowledge_fileMethod · 0.45

Calls 5

saveMethod · 0.95
FileClass · 0.90
readMethod · 0.80
is_validMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected