mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch '1814-Ability_to_use_object_store_for_images' of github.com:steffann/netbox into 1814-Ability_to_use_object_store_for_images
This commit is contained in:
@ -616,13 +616,16 @@ class ImageAttachment(models.Model):
|
|||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
if settings.MEDIA_STORAGE and settings.MEDIA_STORAGE['BACKEND'] == 'S3':
|
if settings.MEDIA_STORAGE and settings.MEDIA_STORAGE['BACKEND'] == 'S3':
|
||||||
from botocore.exceptions import ClientError as AccessError
|
# For S3 we need to handle a different exception
|
||||||
else:
|
from botocore.exceptions import ClientError
|
||||||
AccessError = OSError
|
try:
|
||||||
|
return self.image.size
|
||||||
|
except ClientError:
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.image.size
|
return self.image.size
|
||||||
except AccessError:
|
except OSError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user