Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Filename too long when using download_file #3642

Answered by mdmintz
oooyiyangc asked this question in Q&A
Discussion options

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!

You must be logged in to vote

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

Comment options

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)

You must be logged in to vote
1 reply
Comment options

Thank you @mdmintz for the very quick response! Super helpful--appreciate it!

Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /