Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuadFile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Volkor Barbarian Warrior
QuadFile
Commits
83206a01
Unverified
Commit
83206a01
authored
4 years ago
by
Volkor Barbarian Warrior
Browse files
Options
Downloads
Patches
Plain Diff
Block on extension
parent
3da8126b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+2
-2
2 additions, 2 deletions
README.md
conf.py.sample
+2
-2
2 additions, 2 deletions
conf.py.sample
run.py
+3
-13
3 additions, 13 deletions
run.py
with
7 additions
and
17 deletions
README.md
+
2
−
2
View file @
83206a01
...
...
@@ -5,7 +5,7 @@ A temporary (or permanent, depending on configuration) file sharing service writ
## Features
*
Automatically remove files that aren't accessed often enough
*
Supports all filetypes, with options to filter by
mimetypes
*
Supports all filetypes, with options to filter by
file extension
*
Prevents duplicate filenames
*
Works on all platforms (as long as they can use basic JavaScript)
*
Both easy to set up and use
...
...
@@ -19,7 +19,7 @@ Ignore the submodules directory, this is for my instance.
Needed:
*
Python 3
(Required for python-magic)
*
Python 3
*
sqlite3 package for your OS (To create the database)
*
Install the python requirements with (
``pip install -r requirements.txt``
)
*
nginx or another reverse proxy.
...
...
This diff is collapsed.
Click to expand it.
conf.py.sample
+
2
−
2
View file @
83206a01
...
...
@@ -31,11 +31,11 @@ config["GEN_DELETEKEY"] = False
# File settings
config["UPLOAD_FOLDER"] = './data'
config["ALLOW_ALL_FILES"] = False
config["ALLOWED_
MIMETYPE
S"] = set(['
plain/text', 'application/pdf', 'image/png', 'image/x-png', 'image/jpeg', 'image/gif'
])
config["ALLOWED_
EXTENSION
S"] = set(['
txt', 'pdf', 'bmp', 'png', 'jpg', 'jpeg', 'gif', 'webm', 'log', 'bin', 'webp', 'heif', 'mov', 'mkv', 'mp4', 'mp3', 'ogg', 'flac'
])
# Will use blacklist if this is enabled. You must disable ALLOW_ALL_FILES for this to take effect
config["BLACKLIST"] = True
config["BANNED_
MIMETYPE
S"] = set(['
application/x-dos
exe
c
', '
application/x-msdownload', 'application/x-msdos-program' 'text/html', 'application/javascript', 'application/x-httpd-php', 'application/msi
'])
config["BANNED_
EXTENSION
S"] = set(['exe', '
msi', 'html', 'js', 'php
'])
# If this is set to true, old files will be deleted. TIME is how far behind (in seconds) the last accessed time can be before files get deleted
config["DELETE_FILES"] = True
...
...
This diff is collapsed.
Click to expand it.
run.py
+
3
−
13
View file @
83206a01
...
...
@@ -8,7 +8,7 @@ import os
import
random
import
json
import
time
import
magic
#
import magic
import
secrets
from
random
import
randint
...
...
@@ -77,19 +77,9 @@ def allowed_file(file):
return
True
else
:
if
config
[
"
BLACKLIST
"
]:
if
magic
.
from_buffer
(
file
.
read
(
1024
),
mime
=
True
)
not
in
config
[
"
BANNED_MIMETYPES
"
]:
file
.
seek
(
0
)
# seek back to start so a valid file could be read
return
True
else
:
file
.
seek
(
0
)
return
False
return
'
.
'
in
file
and
file
.
rsplit
(
'
.
'
,
1
)[
1
]
not
in
config
[
"
BANNED_EXTENSIONS
"
]
else
:
if
magic
.
from_buffer
(
file
.
read
(
1024
),
mime
=
True
)
in
config
[
"
ALLOWED_MIMETYPES
"
]:
file
.
seek
(
0
)
return
True
else
:
file
.
seek
(
0
)
return
False
return
'
.
'
in
file
and
file
.
rsplit
(
'
.
'
,
1
)[
1
]
in
config
[
"
ALLOWED_EXTENSIONS
"
]
@app.route
(
'
/
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
upload_file
():
...
...
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