Below is the code, but I would like to leave a comment filename = os.path.basename (filename) , when I do this, I can not specify the absolute path for filename , because k.set_contents_from_filename no longer refers to the actual file location, only the file in the current working directory will work if not to comment. If I do not use file_name = os.path.basename (file name) , the file will be downloaded with a predefined path. Any ideas?
for filename in all_files:
if not os.path.isfile(filename):
continue
k = Key(bucket)
k.key = filename
k.set_contents_from_filename(filename, cb=percent_cb, num_cb=10)
source
share