-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix upload file on fielmanager (#1012)
* Custom django storage for filemanager * Remove odl code * Add X-FRAME-OPTION * Reset effect for input.form-control class --------- Co-authored-by: wlorenzetti <lorenzett@gis3w.it>
- Loading branch information
1 parent
02383f6
commit a7b2a34
Showing
7 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# coding=utf-8 | ||
"""" | ||
File storage for filemanager module | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the Mozilla Public License 2.0. | ||
""" | ||
|
||
__author__ = 'lorenzetti@gis3w.it' | ||
__date__ = '2025-01-18' | ||
__copyright__ = 'Copyright 2015 - 2025, Gis3w' | ||
__license__ = 'MPL 2.0' | ||
|
||
from django.core.files import File | ||
from qdjango.utils.storage import OverwriteStorage | ||
|
||
|
||
class FileManagerOverwriteStorage(OverwriteStorage): | ||
""" | ||
Custom storage for filemanager module | ||
""" | ||
|
||
def save(self, name, content, max_length=None): | ||
""" | ||
Override save method for bypass trasversal storage file checking | ||
""" | ||
# Get the proper name for the file, as it will actually be saved. | ||
if name is None: | ||
name = content.name | ||
|
||
if not hasattr(content, "chunks"): | ||
content = File(content, name) | ||
|
||
# Potentially find a different name depending on storage constraints. | ||
name = self.get_available_name(name, max_length=max_length) | ||
|
||
# The save operation should return the actual name of the file saved. | ||
name = self._save(name, content) | ||
|
||
return name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters