I have to read the zip,rar and 7z file present in the server and extract there itself for further processing. I am using paramiko and python. I have a sftp file but I am not able to pass it through Patool library.
remote_file = sftp_client.open(output[i],'rb')
sftp = ssh_client.open_sftp()
file = ftp.file(output[i], "r", -1)
lines = file.readlines()
print(lines)
patoolib.extract_archive(output[i], outdir=inputPath)
Here output[i]
is remote server zip file path.
You cannot unzip files on remote server using SFTP protocol. That's not possible.
You cannot use client-side libraries to unzip a non-local file either. You would have to download the archive (to a temporary local file or at least to a memory), extract it and upload the extracted files. What can be very slow.
Best you can do (if you have a shell access) is to execute (using SSH) any available command on the remote server to do the extraction.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.