Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
website
Commits
19be800c
Unverified
Commit
19be800c
authored
3 years ago
by
Roman Karwacik
Browse files
Options
Downloads
Patches
Plain Diff
Feature: Use S3 presigned urls instead of direct links
parent
2a200632
Branches
Branches containing commit
No related tags found
1 merge request
!47
Draft: Support for S3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
config.py.example
+5
-0
5 additions, 0 deletions
config.py.example
requirements.txt
+1
-0
1 addition, 0 deletions
requirements.txt
server.py
+18
-1
18 additions, 1 deletion
server.py
with
24 additions
and
1 deletion
config.py.example
+
5
−
0
View file @
19be800c
...
...
@@ -40,3 +40,8 @@ MAIL_DEFAULT = 'Video AG <videoag@fsmpi.rwth-aachen.de>'
MAIL_ADMINS = 'videoag-it@lists.fsmpi.rwth-aachen.de'
STREAMING_SERVER = 'rtmp://video-web-0.fsmpi.rwth-aachen.de/src/'
BACKUP_STREAMING_SERVER = 'rtmp://video-web-1.fsmpi.rwth-aachen.de/src/'
S3_ACCESS_KEY = None
S3_SECRET_KEY = None
S3_ENDPOINT = "http://rgw.fsmpi.rwth-aachen.de:7480"
S3_BUCKET_NAME = "VIDEO.rgw.fsmpi.rwth-aachen.de"
This diff is collapsed.
Click to expand it.
requirements.txt
+
1
−
0
View file @
19be800c
# required
flask
requests
boto3
# optional
lxml
...
...
This diff is collapsed.
Click to expand it.
server.py
+
18
−
1
View file @
19be800c
...
...
@@ -7,6 +7,7 @@ import traceback
import
string
import
locale
import
urllib
import
boto3
from
flask
import
Flask
,
request
,
url_for
,
redirect
,
session
,
render_template
,
flash
,
Response
,
make_response
from
werkzeug.routing
import
Rule
...
...
@@ -39,6 +40,10 @@ if config['DEBUG']:
if
not
config
.
get
(
'
SECRET_KEY
'
,
None
):
config
[
'
SECRET_KEY
'
]
=
os
.
urandom
(
24
)
if
config
.
get
(
"
S3_ACCESS_KEY
"
)
and
config
.
get
(
"
S3_SECRET_KEY
"
):
b3_session
=
boto3
.
Session
(
aws_access_key_id
=
config
[
"
S3_ACCESS_KEY
"
],
aws_secret_access_key
=
config
[
"
S3_SECRET_KEY
"
])
mod_endpoints
=
[]
#pylint: disable=invalid-name
def
mod_required
(
func
):
mod_endpoints
.
append
(
func
.
__name__
)
...
...
@@ -539,6 +544,18 @@ def auth(): #pylint: disable=too-many-branches
@app.route
(
'
/files/<filename>
'
)
def
files
(
filename
):
if
config
.
get
(
"
S3_ACCESS_KEY
"
)
and
config
.
get
(
"
S3_SECRET_KEY
"
):
s3_client
=
b3_session
.
client
(
'
s3
'
,
endpoint_url
=
config
[
"
S3_ENDPOINT
"
])
# creates a presigned url, doesn't check wether the object exists though
try
:
generated_url
=
s3_client
.
generate_presigned_url
(
'
get_object
'
,
Params
=
{
"
Bucket
"
:
config
[
"
S3_BUCKET_NAME
"
],
"
Key
"
:
filename
},
ExpiresIn
=
3600
)
except
:
notify_admins
(
'
s3 error
'
,
traceback
=
"
creating presigned url failed!
"
)
return
None
return
redirect
(
generated_url
)
else
:
return
redirect
(
config
[
'
VIDEOPREFIX
'
]
+
'
/
'
+
filename
)
@app.route
(
'
/sitemap.xml
'
)
...
...
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