core.files.storage.get_valid_name()

get_valid_name(name)

Returns a filename suitable for use with the underlying storage system. The name argument passed to this method is either the original filename sent to the server or, if upload_to is a callable, the filename returned by that method after any path information is removed. Override this to customize how non-standard characters are converted to safe filenames.

Changed in Django 1.9:

In older versions, this method was not called when upload_to was a callable.

The code provided on Storage retains only alpha-numeric characters, periods and underscores from the original filename, removing everything else.

doc_Django
2016-10-09 18:34:45
Comments
Leave a Comment

Please login to continue.