Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
12f5d8f0
Commit
12f5d8f0
authored
Dec 23, 2015
by
Arthur Bressan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
S3FileAdmin convenience class
parent
53658d59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
s3.py
flask_admin/contrib/fileadmin/s3.py
+35
-0
No files found.
flask_admin/contrib/fileadmin/s3.py
View file @
12f5d8f0
...
@@ -10,6 +10,8 @@ except ImportError:
...
@@ -10,6 +10,8 @@ except ImportError:
from
flask
import
redirect
from
flask
import
redirect
from
flask_admin.babel
import
gettext
from
flask_admin.babel
import
gettext
from
.
import
BaseFileAdmin
class
S3Storage
(
object
):
class
S3Storage
(
object
):
"""
"""
...
@@ -162,3 +164,36 @@ class S3Storage(object):
...
@@ -162,3 +164,36 @@ class S3Storage(object):
def
_is_directory_empty
(
self
,
path
):
def
_is_directory_empty
(
self
,
path
):
keys
=
self
.
_get_path_keys
(
path
+
self
.
separator
)
keys
=
self
.
_get_path_keys
(
path
+
self
.
separator
)
return
len
(
keys
)
==
1
return
len
(
keys
)
==
1
class
S3FileAdmin
(
BaseFileAdmin
):
"""
Simple Amazon Simple Storage Service file-management interface.
:param bucket_name:
Name of the bucket that the files are on.
:param region:
Region that the bucket is located
:param aws_access_key_id:
AWS Access Key ID
:param aws_secret_access_key:
AWS Secret Access Key
Sample usage::
from flask_admin import Admin
from flask_admin.contrib.fileadmin.s3 import S3FileAdmin
admin = Admin()
admin.add_view(S3FileAdmin('files_bucket', 'us-east-1', 'key_id', 'secret_key')
"""
def
__init__
(
self
,
bucket_name
,
region
,
aws_access_key_id
,
aws_secret_access_key
,
*
args
,
**
kwargs
):
storage
=
S3Storage
(
bucket_name
,
region
,
aws_access_key_id
,
aws_secret_access_key
)
super
(
S3FileAdmin
,
self
)
.
__init__
(
*
args
,
storage
=
storage
,
**
kwargs
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment