-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-use already downloaded input images for serverless (thanks Calvin!)
- Loading branch information
1 parent
9147eb5
commit 218c035
Showing
4 changed files
with
55 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
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,24 @@ | ||
import glob | ||
import magic | ||
import mimetypes | ||
|
||
class Filesystem: | ||
def __init__(self): | ||
pass | ||
|
||
@staticmethod | ||
def find_input_file(directory, str_hash): | ||
# Hashed url should have only one result | ||
try: | ||
matched = glob.glob(f'{directory}/{str_hash}*') | ||
if len(matched) > 0: | ||
return matched[0] | ||
return None | ||
except: | ||
return None | ||
|
||
@staticmethod | ||
def get_file_extension(filepath): | ||
mime_str = magic.from_file(filepath, mime=True) | ||
return mimetypes.guess_extension(mime_str) | ||
|
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