Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3 config but storages saving files locally #27

Open
ashton opened this issue Jan 9, 2018 · 1 comment
Open

s3 config but storages saving files locally #27

ashton opened this issue Jan 9, 2018 · 1 comment

Comments

@ashton
Copy link

ashton commented Jan 9, 2018

Hi,

I have followed the documentation and configured flask-fs to use S3 Backend, but when I save a file, it is being saved locally.

App configuration:

>>> app.config
<Config {
'JSON_AS_ASCII': True,
'SESSION_REFRESH_EACH_REQUEST': True,
u'FS_SERVE': False,
u'FS_BACKEND': 's3',
'FS_S3_SECRET_KEY': '**secret key**',
u'FS_URL': None,
'SERVICE_TIMEOUT': 5,
u'FS_IMAGES_OPTIMIZE': False,
'MAX_CONTENT_LENGTH': None,
'SESSION_COOKIE_DOMAIN': None,
'SESSION_COOKIE_NAME': 'session',
'LOGGER_HANDLER_POLICY': 'always',
u'FS_PREFIX': None,
'DATE_FORMAT': '%Y-%m-%d',
'DATE_TIME_FORMAT': '%Y-%m-%d %H:%M',
'PERMANENT_SESSION_LIFETIME': datetime.timedelta(31),
'TRAP_HTTP_EXCEPTIONS': False,
'PRESERVE_CONTEXT_ON_EXCEPTION': None,
'SESSION_COOKIE_PATH': None,
'LOGGER_NAME': 'api.app',
'FS_S3_ACCESS_KEY': '**api key**',
u'FS_ROOT': u'/app/instance/fs','
APPLICATION_ROOT': None,
'SERVER_NAME': None,
'PREFERRED_URL_SCHEME': 'http',
'TESTING': False,
'TEMPLATES_AUTO_RELOAD': None,
'FS_S3_ENDPOINT': 'https://s3-us-west-2.amazonaws.com',
'JSONIFY_MIMETYPE': 'application/json',
'USE_X_SENDFILE': False,
'FS_S3_REGION': 'us-west-2', 
'SESSION_COOKIE_SECURE': False,
'DEBUG': False,
'EXPLAIN_TEMPLATE_LOADING': False,
'MAX_NUM_IMAGES_PER_EXP': 5,
'JSONIFY_PRETTYPRINT_REGULAR': True,
'PROPAGATE_EXCEPTIONS': None,
'TRAP_BAD_REQUEST_ERRORS': False,
'JSON_SORT_KEYS': True,
'SESSION_COOKIE_HTTPONLY': True,
'SEND_FILE_MAX_AGE_DEFAULT': datetime.timedelta(0, 43200)}>

in app.py:

storage = fs.Storage('images', fs.IMAGES, overwrite=True)
fs.init_app(app, storage)

but if I execute flask shell:

>>> app.extensions
{u'fs': {'images': <flask_fs.storage.Storage object at 0x7fd157ea5a10>}}

>>> app.extensions.get('fs').get('images')
<flask_fs.storage.Storage object at 0x7fd157ea5a10>

>>> app.extensions.get('fs').get('images').backend
<flask_fs.backends.local.LocalBackend object at 0x7fd157ea5f90>

any insights of what am I doing wrong?

@AbdealiLoKo
Copy link

While I cannot see anything wrong in your configs -

FS_S3_ACCESS_KEY = '.....'
FS_S3_SECRET_KEY = '.....'
FS_BACKEND = 's3'
FS_S3_ENDPOINT = None
FS_S3_REGION = None

with

storage = fs.Storage('mybucketname')
fs.init_app(app, storage)

worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants