S3ReaderWriter.py 403 B

123456789101112131415161718
  1. from magic_pdf.io import AbsReaderWriter
  2. class DiskReaderWriter(AbsReaderWriter):
  3. def __init__(self, parent_path, encoding='utf-8'):
  4. self.path = parent_path
  5. self.encoding = encoding
  6. def read(self):
  7. with open(self.path, 'rb') as f:
  8. return f.read()
  9. def write(self, data):
  10. with open(self.path, 'wb') as f:
  11. f.write(data)