-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9584a6f
commit 6543ea4
Showing
15 changed files
with
507 additions
and
59 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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,34 @@ | ||
from pydrive.drive import GoogleDrive | ||
from pydrive.auth import GoogleAuth | ||
import os | ||
import dropbox | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
class dropbox_client: | ||
def __init__(self,access_token): | ||
|
||
self.dbx = dropbox.Dropbox(access_token) | ||
logger.info("Created a dropbox client") | ||
|
||
try: | ||
self.dbx.files_create_folder("/airlift") | ||
except dropbox.exceptions.ApiError as e: | ||
print(f"The folder airlift already exists.") | ||
|
||
def upload_to_dropbox(self,filename): | ||
with open(filename, 'rb') as f: | ||
image_data = f.read() | ||
image_name = os.path.basename(filename) | ||
|
||
dropbox_path = f"/airlift/{image_name}" | ||
|
||
# Upload the image | ||
self.dbx.files_upload(image_data, dropbox_path) | ||
|
||
shared_link_metadata = self.dbx.sharing_create_shared_link(path=dropbox_path) | ||
shared_url = shared_link_metadata.url | ||
|
||
|
||
direct_download_url = shared_url.replace('www.dropbox.com', 'dl.dropboxusercontent.com').replace('?dl=0', '?dl=1') | ||
|
||
return direct_download_url |
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
Oops, something went wrong.