Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
2507ecc2
Commit
2507ecc2
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Create upload directory if it does not exist
parent
b07181fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!125
Move path_and_rename to core_helpers.py and delete old helper.py
Pipeline
#675
failed
5 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/util/core_helpers.py
+3
-0
3 additions, 0 deletions
aleksis/core/util/core_helpers.py
with
3 additions
and
0 deletions
aleksis/core/util/core_helpers.py
+
3
−
0
View file @
2507ecc2
...
...
@@ -133,5 +133,8 @@ def path_and_rename(instance, filename: str, upload_to: str = "files") -> str:
# set filename as random string
new_filename
=
'
{}.{}
'
.
format
(
uuid4
().
hex
,
ext
)
# Create upload directory if necessary
os
.
makedirs
(
os
.
path
.
join
(
settings
.
MEDIA_ROOT
,
upload_to
),
exist_ok
=
True
)
# return the whole path to the file
return
os
.
path
.
join
(
upload_to
,
new_filename
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment