-
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.
able to upload and get back a file. tested.
- Loading branch information
Showing
6 changed files
with
67 additions
and
20 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .save import save | ||
from .restore import restore | ||
from .restore import restore, download | ||
from .add_file import add_file | ||
from .google_drive import upload_file, get_service |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import os | ||
|
||
from .cloudfile import CloudFile | ||
from .google_drive import upload_file | ||
|
||
|
||
def add_file(file: str, cloudf: CloudFile = None, hard=False): | ||
if cloudf is None: | ||
cloudf = CloudFile() | ||
assert os.path.isfile(file) | ||
|
||
return cloudf.upload_file(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 was deleted.
Oops, something went wrong.
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,17 @@ | ||
import os | ||
import cloudfile | ||
from tests.utils import del_folder | ||
|
||
|
||
def test_add_file(): | ||
if not os.path.isdir("foo"): | ||
os.mkdir("foo") | ||
filename = "foo/bar_new.txt" | ||
with open(filename, "w") as f: | ||
f.write("hello world") | ||
url = cloudfile.add_file(filename) | ||
os.remove(filename) | ||
cloudfile.download(filename, url) | ||
assert os.path.isfile(filename) | ||
del_folder("foo") | ||
|