Opened 4 months ago

Closed 4 months ago

#35513 closed Uncategorized (duplicate)

Add a `seprarate_dirname_file`name method in core file storage

Reported by: Fournet Enzo Owned by: nobody
Component: Core (Other) Version: 5.1
Severity: Normal Keywords: Storage File Core Storage
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In /files/storage/base.py file, here's some code that separating filename and dirname so here we can add a separate_dirname_filename method that allows us to modify how Django separates the filename from the dirname when storing a file without fully rewriting any method that needs to perform this separation. This can be useful when a file has a double extension, such as .json.sbom or anything similar, and we don't want to break the extension.

Method example :

def seprarate_dirname_filename(self, filename):
        """
        Return a tuple of dirname and filename.
        This method can be overridden to customize how the filename is split.
        """
        return os.path.split(filename)

With this upgrade, we are able to let people override the Storage Class and only rewrite this new method to be sure that Django don't broke some specific file name or extension, that needed.

Attachments (1)

base.py (4.7 KB ) - added by Fournet Enzo 4 months ago.

Download all attachments as: .zip

Change History (2)

by Fournet Enzo, 4 months ago

Attachment: base.py added

comment:1 by Sarah Boyce, 4 months ago

Resolution: duplicate
Status: newclosed

Hi Fournet, the example you gave feels like a duplicate to #23759 which is now fixed.
Can you check whether the customization is still needed based off main? Or give more examples?

Note: See TracTickets for help on using tickets.
Back to Top