I am aware you are can upload multiple files to post in an api using this,
ex.
test_files = {
"test_file_1": open("my_file.txt", "rb"),
"test_file_2": open("my_file_2.txt", "rb"),
"test_file_3": open("my_file_3.txt", "rb")
}
but i want to change the files often so the solution i thought of is to drop all the files in a folder and loop through the folder to upload each file.
the part i am stuck on is how can i loop though the folder
path = "/Users/mycode/Documents/API_upload/"
files = {
'file': open(p,'rb') for p in os.listdir(path)
}
I tried this but doesnt work as the files need to be in the directory for it to work. any other suggestions for this.
thanks.