Reference

Cores

class flask_s3_viewer.FlaskS3Viewer(app: Flask | None = None, namespace: str | None = None, object_hostname: str | None = None, allowed_extensions: set[str] | None = None, template_namespace: str | None = None, upload_type: str = 'default', title: str | None = None, logo_url: str | None = None, logo_path: str | None = None, logo_link_url: str | None = None, template_folder: str | None = None, auth_callback: Any = None, permission_callback: Any = None, visible_namespaces_callback: Any = None, google_client_id: str | None = None, google_client_secret: str | None = None, allowed_emails: list[str] | set[str] | None = None, allowed_domains: list[str] | set[str] | None = None, config: dict | None = None)

Bases: AWSS3Client

v1.0 breaking change:
  • Singleton 메타클래스 제거.

  • 동일 namespace 재초기화 시 ValueError raise.

  • blueprint는 첫 init_app 호출에서 자동 등록되며 `register()`는 제거됨.

  • get_instance/get_boto_client/`get_boto_session`은 staticmethod(app, namespace).

class FLASK_S3_VIEWER_BUCKET(profile_name, region_name, endpoint_url, bucket_name, secret_key, access_key, session_token, cache_dir, ttl, use_cache, timezone, verify, base_path, role_arn, role_session_name, external_id, duration_seconds, mfa_serial, token_code, token_code_callback)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__match_args__ = ('profile_name', 'region_name', 'endpoint_url', 'bucket_name', 'secret_key', 'access_key', 'session_token', 'cache_dir', 'ttl', 'use_cache', 'timezone', 'verify', 'base_path', 'role_arn', 'role_session_name', 'external_id', 'duration_seconds', 'mfa_serial', 'token_code', 'token_code_callback')
static __new__(_cls, profile_name, region_name, endpoint_url, bucket_name, secret_key, access_key, session_token, cache_dir, ttl, use_cache, timezone, verify, base_path, role_arn, role_session_name, external_id, duration_seconds, mfa_serial, token_code, token_code_callback)

Create new instance of FLASK_S3_VIEWER_BUCKET(profile_name, region_name, endpoint_url, bucket_name, secret_key, access_key, session_token, cache_dir, ttl, use_cache, timezone, verify, base_path, role_arn, role_session_name, external_id, duration_seconds, mfa_serial, token_code, token_code_callback)

__repr__()

Return a nicely formatted representation string

__slots__ = ()
_asdict()

Return a new dict which maps field names to their values.

_field_defaults = {}
_fields = ('profile_name', 'region_name', 'endpoint_url', 'bucket_name', 'secret_key', 'access_key', 'session_token', 'cache_dir', 'ttl', 'use_cache', 'timezone', 'verify', 'base_path', 'role_arn', 'role_session_name', 'external_id', 'duration_seconds', 'mfa_serial', 'token_code', 'token_code_callback')
classmethod _make(iterable)

Make a new FLASK_S3_VIEWER_BUCKET object from a sequence or iterable

_replace(**kwds)

Return a new FLASK_S3_VIEWER_BUCKET object replacing specified fields with new values

access_key

Alias for field number 5

base_path

Alias for field number 12

bucket_name

Alias for field number 3

cache_dir

Alias for field number 7

duration_seconds

Alias for field number 16

endpoint_url

Alias for field number 2

external_id

Alias for field number 15

mfa_serial

Alias for field number 17

profile_name

Alias for field number 0

region_name

Alias for field number 1

role_arn

Alias for field number 13

role_session_name

Alias for field number 14

secret_key

Alias for field number 4

session_token

Alias for field number 6

timezone

Alias for field number 10

token_code

Alias for field number 18

token_code_callback

Alias for field number 19

ttl

Alias for field number 8

use_cache

Alias for field number 9

verify

Alias for field number 11

FLASK_S3_VIEWER_BUCKET_CONFIGS: dict = {}
__annotations__ = {'FLASK_S3_VIEWER_BUCKET_CONFIGS': <class 'dict'>, '__max_items': 'int', '__max_pages': 'int', '_auth_allowed_domains': 'list[str] | set[str] | None', '_auth_allowed_emails': 'list[str] | set[str] | None', '_base_path': 'str', '_bucket_name': 'str | None', '_cache': 'AWSCache', '_s3': 'Any', '_session': 'Session', 'allowed_extensions': 'set[str] | None', 'app': 'Flask | None', 'auth_enabled': 'bool', 'display_timezone': 'ZoneInfo | None', 'google_client_id': 'str | None', 'google_client_secret': 'str | None', 'logo_link_url': 'str | None', 'logo_url': 'str | None', 'namespace': 'str | None', 'object_hostname': 'str | None', 'profile_name': 'str | None', 'region_name': 'str | None', 'runnable': 'bool', 'template_folder': 'str | None', 'title': 'str', 'upload_type': 'str', 'use_cache': 'bool'}
__init__(app: Flask | None = None, namespace: str | None = None, object_hostname: str | None = None, allowed_extensions: set[str] | None = None, template_namespace: str | None = None, upload_type: str = 'default', title: str | None = None, logo_url: str | None = None, logo_path: str | None = None, logo_link_url: str | None = None, template_folder: str | None = None, auth_callback: Any = None, permission_callback: Any = None, visible_namespaces_callback: Any = None, google_client_id: str | None = None, google_client_secret: str | None = None, allowed_emails: list[str] | set[str] | None = None, allowed_domains: list[str] | set[str] | None = None, config: dict | None = None) None
Parameters:
  • app (Flask.app) – Flask application (Optional, v1.0+). If provided, extension is auto-registered. Otherwise call init_app() later.

  • namespace (str) – Unique namespace of Flask S3Viewer (Required)

  • object_hostname (url) – Hostname, e.g. Cloudfront endpoint

  • allowed_extensions (set) – e.g. {‘jpg’, ‘png’}

  • template_namespace (str) – DEPRECATED — templates were unified in v1.0. Passing this argument emits a DeprecationWarning and the value is ignored.

  • upload_type (str) – Upload type

  • title (str) – Heading + browser title text. Defaults to "Flask S3 Viewer".

  • logo_url (str) – URL of a custom logo image (absolute URL, Flask url_for result, or any browser-resolvable path).

  • logo_path (str) – Local filesystem path to a logo image. It is read once and inlined as a data: URI — convenient when you don’t want to expose the file via a separate static route. logo_path takes precedence over logo_url.

  • logo_link_url (str) – Optional override for the click target of the header logo + title anchor. When set, the anchor renders as a plain <a href="..."> pointing at this URL and the default HTMX swap (which navigates back to the namespace root listing) is disabled — useful when the deployer wants the brand mark to return users to an external dashboard / home page. Omit (or leave as None) to keep the v1.2 behaviour where the anchor performs an in-place HTMX listing reset.

  • template_folder (str) – Optional path to a directory containing overrides for any of the bundled templates (layout.html, files.html, _file_list.html, _pagination.html, _upload_form.html, error.html). Files in this folder are preferred by Jinja over the bundled originals. Scaffold a ready-to-edit starting point with flask_s3_viewer -p ./out.

  • visible_namespaces_callback (callable) – Optional callback(email, registry) -> iterable[str] used to hide namespaces the current user should not see in the bucket switcher. Security still comes from permission_callback.

  • config (dict) – Bucket configs

static _install_template_override(app: Flask, folder: str) None

Prepend folder to the app’s Jinja loader so its templates win.

Uses Flask’s ChoiceLoader + FileSystemLoader pattern so other blueprints’ template resolution is untouched.

add_new_one(namespace: str | None = None, object_hostname: str | None = None, allowed_extensions: set[str] | None = None, template_namespace: str | None = None, upload_type: str = 'default', title: str | None = None, logo_url: str | None = None, logo_path: str | None = None, logo_link_url: ~typing.Any = <object object>, template_folder: str | None = None, auth_callback: ~typing.Any = <object object>, permission_callback: ~typing.Any = <object object>, visible_namespaces_callback: ~typing.Any = <object object>, google_client_id: ~typing.Any = <object object>, google_client_secret: ~typing.Any = <object object>, allowed_emails: ~typing.Any = <object object>, allowed_domains: ~typing.Any = <object object>, config: dict | None = None) FlaskS3Viewer

Initialize another bucket bound to the same Flask app.

Parameters:
  • namespace (str) – Unique namespace of Flask S3Viewer

  • object_hostname (url) – Hostname, e.g. Cloudfront endpoint

  • allowed_extensions (set) – e.g. {‘jpg’, ‘png’}

  • template_namespace (str) – DEPRECATED — see __init__().

  • upload_type (str) – Upload type

  • title (str) – Heading + browser title text for this namespace.

  • logo_url (str) – Optional custom logo URL.

  • logo_path (str) – Optional local logo path.

  • logo_link_url (str) – Optional override for the header logo + title anchor click target. Omit to inherit the parent viewer’s value; pass None to drop the override on this child namespace (restoring the default HTMX listing reset); pass a string to use a different URL than the parent.

  • template_folder (str) – Optional template override folder.

  • auth_callback (callable) – Optional auth callback. Omit to inherit the parent viewer’s value; pass None explicitly to disable auth on the child namespace (subject to __init__ Google OAuth wiring); pass a callable to use a different callback than the parent.

  • permission_callback (callable) – Optional permission callback. Same omit/None/value semantics as auth_callback.

  • visible_namespaces_callback (callable) – Optional bucket switcher visibility callback. Same omit/None/value semantics.

  • google_client_id (str) – Optional Google OAuth client ID. Omit to inherit; None to disable OAuth on the child namespace.

  • google_client_secret (str) – Optional Google OAuth client secret. Pair with google_client_id; same omit/None semantics.

  • allowed_emails – Optional allowlist of literal emails. Omit to inherit the parent’s; None/empty to drop the allowlist.

  • allowed_domains – Optional allowlist of domains. Omit to inherit the parent’s; None/empty to drop the allowlist.

  • config (dict) – Bucket configs

Return:

FlaskS3Viewer

static get_boto_client(app: Flask, namespace: str) Any

Return the underlying boto3 S3 client for the given app + namespace.

static get_boto_session(app: Flask, namespace: str) Any

Return the underlying boto3 Session for the given app + namespace.

static get_instance(app: Flask, namespace: str) FlaskS3Viewer

Return a Flask S3Viewer instance for the given app + namespace.

v1.0 breaking: previously get_instance(namespace) returned the global Singleton entry. It now requires an explicit app argument (or use current_app.extensions['flask_s3_viewer'][namespace] from within a request).

init_app(app: Flask) None

Register this FlaskS3Viewer instance to a Flask application.

  • Stores the instance in app.extensions['flask_s3_viewer'][namespace].

  • Registers the blueprint once per app (first init_app call).

  • Raises ValueError if the namespace is already registered for the given app (this is the v1.0 breaking change replacing Singleton’s silent reuse semantics).

property max_items: int
property max_pages: int

Region

class flask_s3_viewer.aws.ref.Region(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

AWS Service Regions

Reference:

https://docs.aws.amazon.com/general/latest/gr/rande.html

Usage:

Region.SEOUL.value

BAHRAIN = 'me-south-1'
BEIJING = 'cn-north-1'
CALIFORNIA = 'us-west-1'
CANADA = 'ca-central-1'
FRANKFURT = 'eu-central-1'
HONGKONG = 'ap-east-1'
IRELAND = 'eu-west-1'
LONDON = 'eu-west-2'
MUMBAI = 'ap-south-1'
NINGXIA = 'cn-northwest-1'
OHIO = 'us-east-2'
OREGON = 'us-west-2'
OSAKA = 'ap-northeast-3'
PARIS = 'eu-west-3'
SAOPAULO = 'sa-east-1'
SEOUL = 'ap-northeast-2'
SINGAPORE = 'ap-southeast-1'
STOCKHOLM = 'eu-north-1'
SYDNEY = 'ap-southeast-2'
TOKYO = 'ap-northeast-1'
VIRGINIA = 'us-east-1'