MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / share_local_file

Method share_local_file

apps/admin/services.py:1466–1494  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

1464 }
1465
1466 async def share_local_file(self, item):
1467 local_file = LocalFileClass(item.filename)
1468 if not await local_file.exists():
1469 raise HTTPException(status_code=404, detail="文件不存在")
1470
1471 text = await local_file.read()
1472 expired_at, expired_count, used_count, code = await get_expire_info(
1473 item.expire_value, item.expire_style
1474 )
1475 path, suffix, prefix, uuid_file_name, save_path = await get_file_path_name(item)
1476
1477 await self.file_storage.save_file(text, save_path)
1478
1479 await FileCodes.create(
1480 code=code,
1481 prefix=prefix,
1482 suffix=suffix,
1483 uuid_file_name=uuid_file_name,
1484 file_path=path,
1485 size=local_file.size,
1486 expired_at=expired_at,
1487 expired_count=expired_count,
1488 used_count=used_count,
1489 )
1490
1491 return {
1492 "code": code,
1493 "name": local_file.file,
1494 }
1495
1496
1497class ConfigService:

Callers 1

share_local_fileFunction · 0.80

Calls 6

existsMethod · 0.95
readMethod · 0.95
get_expire_infoFunction · 0.90
get_file_path_nameFunction · 0.90
LocalFileClassClass · 0.85
save_fileMethod · 0.45

Tested by

no test coverage detected