I want to convert scan PDF to OCR PDF. My code is working if files is in local directories. But if I'm using SFTP the problem occurs. When I use convert_from_path using SFTP, I got an error:
expected str, bytes or os.PathLike object, not SFTPFile
How to read SFTP file path in pdf2image convert_to_path?
Here's my code:
for path in sftp.listdir_attr(file_path):
file = file_path + path.filename
f_name = path.filename
with sftp.open(file) as my_file:
print(my_file)
pages = convert_from_path(my_file, 200)
The my_file is like this, not pathlib.path:
<paramiko.sftp_file.SFTPFile object at 0x7fa22ed55250>
<paramiko.sftp_file.SFTPFile object at 0x7fa22ed55160>