-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Filename too long when using download_file
#3642
-
Hello! I'm very excited to discover this package after using basic Selenium for quite some time and I immediately migrated many of my projects over--really appreciate your effort creating and maintaining this package!
Recently, I'm working on a script to automatically download images after collect their URLs. I'm using the following code block as recommended in other discussions
sb.download_file(full_image_url)
sb.assert_downloaded_file(original_filename)
downloaded_path = sb.get_path_of_downloaded_file(original_filename)
However, I bumped into a filename length issue during download (e.g. [Errno 63] File name too long: 'downloaded_files/img?id=XXXXXX&brightness=0&contrast=0&invert=0&ts=1&cacheable=1&iat=eyJ0eXAiOiJKV1QiXXXXXXXXXXXX.eyJwIjo0OTUwMjg5LCJpYXQiO...
) Since the URL to the image is very long, the filename exceeds the max length (255 characters) allowed on my system. Is there any way to assign a filename before/during downloading? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions
You have to use save_file_as()
so that you can rename the file to a legal size for your file system:
self.save_file_as(file_url, new_file_name, destination_folder=None)
Some other helpful ideas may be found here: s3tools/s3cmd#202 (comment)
Replies: 1 comment 1 reply
-
You have to use save_file_as()
so that you can rename the file to a legal size for your file system:
self.save_file_as(file_url, new_file_name, destination_folder=None)
Some other helpful ideas may be found here: s3tools/s3cmd#202 (comment)
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you @mdmintz for the very quick response! Super helpful--appreciate it!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1