I am able to tar a file successfully on the fly using subprocess.run, but I was not able to send the tar file using send_file option due to the following error:
AttributeError: 'bytes' object has no attribute 'read'
Using subprocess.Popen I was able to tar and send files successfully which are small in size (barely upto 1GB).But there is a problem while taring the files up to 4GB with subprocess.Popen, as subprocess.Popen is using memory to tar.
So I have moved to subprocess.run...but this is failing with the above error.
Please find the code snippet:
process = subprocess.run(['tar', '-cvf', '-', test_dir], stdout=subprocess.PIPE)
send_file(process.stdout, as_attachment=True, attachment_filename=test_dir.tar)
send_file is from flask framework.
Would appreciate any help with the above.