I need to remove each image after uploading it to my server I use paramiko to upload images:
remote_dir = "/path/on/remote/server/"
with sftp.Server("user", "pass", "www.example.com") as server:
for image in glob.glob("/local/path/to/*.png"):
base = path.basename(image)
server.upload(image, path.join(remote_dir, base))
os.remove(image)
However, each image is removed, before upload function finishes its work.
How can I run os.remove(image)
after server.upload
uploads an image to the server successfully? I am new to python and heard about python-callback, but don't know how to use it in this situation.