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

Use blob.time_created #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 1 addition & 6 deletions django_gcloud_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django.utils.encoding import force_str, smart_str
from google.cloud import _helpers as gcloud_helpers
from google.cloud import storage
from google.cloud.exceptions import NotFound
from google.cloud.storage.bucket import Bucket
Expand Down Expand Up @@ -185,11 +184,7 @@ def created_time(self, name):

blob = self.bucket.get_blob(name)

# google.cloud doesn't provide a public method for this
value = blob._properties.get("timeCreated", None)
if value is not None:
naive = datetime.datetime.strptime(value, gcloud_helpers._RFC3339_MICROS)
return naive.replace(tzinfo=gcloud_helpers.UTC)
return blob.time_created if blob else None

def delete(self, name):
name = safe_join(self.bucket_subdir, name)
Expand Down