Skip to content

Fix #86 -- Catch and log file not found exception #91

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

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion s3file/middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import logging
import os

from botocore.exceptions import ClientError
from django.core.files.storage import default_storage

logger = logging.getLogger('s3file')


class S3FileMiddleware:

Expand All @@ -22,4 +26,7 @@ def get_files_from_storage(paths):
for path in paths:
f = default_storage.open(path)
f.name = os.path.basename(path)
yield f
try:
yield f
except ClientError:
logger.exception("File not found: %s", path)