This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#122: implement google cloud support
- Loading branch information
1 parent
c6da306
commit c497ef1
Showing
10 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ aws-credentials | |
.mypy_cache | ||
.idea | ||
.python-version | ||
gcloud-credentials.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import base64 | ||
import binascii | ||
from typing import Optional | ||
|
||
from google.api_core.exceptions import NotFound | ||
from storages.backends.gcloud import GoogleCloudStorage | ||
|
||
from .base import CachingHashStrategy | ||
|
||
|
||
class GoogleCloudStrategy(CachingHashStrategy[GoogleCloudStorage]): | ||
delete_not_found_exception = (NotFound,) | ||
|
||
def get_remote_file_hash(self, prefixed_path): | ||
# type: (str) -> Optional[str] | ||
normalized_path = prefixed_path.replace("\\", "/") | ||
blob = self.remote_storage.bucket.get_blob(normalized_path) | ||
if blob is None: | ||
return blob | ||
md5_base64 = blob._properties["md5Hash"] | ||
return binascii.hexlify(base64.urlsafe_b64decode(md5_base64)).decode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ coveralls | |
django-storages | ||
boto3 | ||
boto | ||
google-cloud-storage |