Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect max_length when AWS_S3_FILE_OVERWRITE=True #513

Closed
a1Gupta opened this issue Jun 29, 2018 · 1 comment
Closed

Respect max_length when AWS_S3_FILE_OVERWRITE=True #513

a1Gupta opened this issue Jun 29, 2018 · 1 comment

Comments

@a1Gupta
Copy link

a1Gupta commented Jun 29, 2018

get_available_name method of S3Boto3Storage doesn't respect max_length.

The Django Storage's get_available_name method truncates the file name if it's length is more than max_length.

When AWS_S3_FILE_OVERWRITE=True and len(file_name) > max_length, this results in Database error - DataError: (1406, "Data too long for column 'file_field' at row 1").

    def get_available_name(self, name, max_length=None):
        """Overwrite existing file with the same name."""
        if self.file_overwrite:
            name = self._clean_name(name)
           >>  ** CHANGE REQUIRED HERE: max_length VALIDATION  **
            return name
        return super(S3Boto3Storage, self).get_available_name(name, max_length)

Validation for max_length should be added to the overridden method, when file_overwrite=True.

@jschneier
Copy link
Owner

Have opened provisional PR at #554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants